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?

Python仮想環境関連コマンド備忘

Posted at

はじめに

Pythonをたまにしか使用していないので、毎回忘れてしまうvenvやpython関係コマンドの備忘内容を記載します。実行環境はWSL2のUbuntu 22.04.2 LTSです。

pyenv

pyenvインストール

githubからgit clone

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

.bashrcに追記

export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

シェルに反映

source ~/.bash_aliases

pyenv使用方法

利用できるpythonバージョン確認

pyenv install -l

バージョン指定でインストール

pyenv install 3.10.14

バージョン指定でアンインストール

pyenv uninstall 3.10.14

インストール済みのバージョン確認

pyenv versions

バージョン切り替え

global指定

pyenv global 3.10.14

shell指定

pyenv shell 3.10.14

local指定

pyenv local 3.10.14

仮想環境(venv)

仮想環境作成

pyenvで作成したいpythonバージョンに切り替えて実行

python -m venv [仮想環境名]

仮想環境有効化

. [仮想環境名]/bin/activate

仮想環境無効化

(仮想環境名) deactivate

pythonバージョン確認

(仮想環境名) python --version
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?