0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

python 自分メモ

Last updated at Posted at 2022-12-05

インストール

Visual Studio Code

・全部デフォルトでインストール

Python

・Customize Installationを選び、「install for all user」(launcher,python本体ともに)
・Add python to environment variables

pipenv

・コマンドプロンプトを管理者として起動(一般ユーザだとユーザホームにインストールされ、path追加が必要)

pip install pipenv

プロジェクト

・システムに環境変数を追加(PIPENV_VENV_IN_PROJECT=true)
 仮想環境がプロジェクトディレクトリ配下(.venv)に作成される。設定しないとユーザホームに作成される。
・プロジェクトフォルダでコマンドを実行

  pipenv install

・プロジェクトフォルダをvs codeで開く
・ファイル→ユーザ設定→設定で、「python.venv path」に「.venv」を設定

pipenvあれこれ

仮想環境を作成(python x.y)

pipenv --python x.y

ディレクトリ内のPipfileを元に仮想環境を構築

pipenv install

仮想環境にライブラリをインストールする

インストール後、Pipfileに追加される
version指定も可能

pipenv install [package]

仮想環境のライブラリ削除

Pipfileからもエントリが削除される
※依存ライブラリは削除されない

pipenv uninstall [package]

シェルを起動

pipenv shell

シェルを抜ける

exit

仮想環境でコマンドを実行

pipenv run [コマンド]

仮想環境を削除

pipenv --rm

仮想環境のパスを確認

pipenv --venv

pipenv留意点

プロジェクトディレクトリを移動すると、仮想環境の再構築が必要(どうにもならないらしい)

pyinstaller

pyinstaller hoge.py --onefile
pyinstaller hoge.py -F

おまけ(venv)

シェルを起動

activate.ps1

シェルを終了

deactivate.ps1

py

シェルを起動

py

バージョン指定でシェルを起動

py -3.11
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?