0
2

More than 1 year has passed since last update.

Python環境構築チートシート

Last updated at Posted at 2023-07-26

pyコマンド

environment_py.py
# 起動バージョン確認1
> py --list-paths
Installed Pythons found by C:\Windows\py.exe Launcher for Windows
 -3.10-64       C:\Python310\python.exe *
 -3.7-64        C:\Python37\python.exe

# ※C:\Windows に py.ini を配置
# 起動バージョン確認2
> py --list-paths
Installed Pythons found by C:\Windows\py.exe Launcher for Windows
 -3.10-64       C:\Python310\python.exe
 -3.7-64        C:\Python37\python.exe *

# 仮想環境の作成
> py -3.10 -m venv wakasama

# 仮想環境の有効化
> .\wakasama\Scripts\activate
(wakasama) >

# 仮想環境の無効化
(wakasama) > deactivate
> 

# 仮想環境の削除 → wakasamaフォルダを消せばよい!!

# 仮想環境の構築
py -3.11 -m venv wakasama311
# 仮想環境の有効化
.\wakasama311\Scripts\activate
# パッケージインストール
python -m pip install --upgrade pip
pip install ipywidgets
---
from ipywidgets import IntProgress
IntProgress(50,max=100)
---
pip install ipywidgets-toggle-buttons
pip install numpy matplotlib
# うまく描画されないときは[Restart Kernel]


C:\wakasama\Python> py -3.11 -m venv wakasama311
.\wakasama311\Scripts\activate


pip install --no-index --find-links=./downloadFiles selenium
pip install --no-index --find-links=./downloadFiles flake8
pip install --no-index --find-links=./downloadFiles autopep8


pip download tzdata --dest pipPackage4 --verbose --log download4.log
pip download mypy --dest pipPackage5 --verbose --log download5.log

pip install pip-licenses

pip-licenses

py.ini
[defaults]
python=3.7

pipコマンド

environment_pip.py

# 初期インストール状態
> pip list
Package    Version
---------- -------
pip        22.2.2
setuptools 63.2.0

# ヘルプ表示
> pip help download
割愛(ヘルプ内容が表示)

# seleniumダウンロード(依存関係パッケージも含む)
> pip download selenium --dest pipPackage --verbose --log download.log

# パッケージ情報表示 ※ライセンスや依存関係パッケージ等
> pip show selenium

# 一括アンインストール
> pip freeze > uninstall.txt
> pip uninstall -y -r uninstall.txt

参考サイト

◆Pythonの複数バージョンの扱い方(Windowsの場合)
 https://gammasoft.jp/python/python-version-management/
◆py コマンドの規定 Python バージョンの設定方法
 https://itpc.blog.fc2.com/blog-entry-225.html
◆オフライン環境でPythonパッケージをpipインストール
 https://densan-hoshigumi.com/develop/python-pip-offline-install

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2