LoginSignup
0
0

More than 1 year has passed since last update.

ubuntu20.04環境でvenvを使ってpythonの環境構築した際のメモ

Posted at

venvはpython用の仮想環境
少なくともpython3.7以降であればvenvが標準でよく利用されているようなので折角なので使っていきたい

venv --- 仮想環境の作成
仮想環境の作成
仮想環境 を作成するには venv コマンドを実行します:
python3 -m venv /path/to/new/virtual/environment

/path/to/new/virtual/environmentには実際のディレクトリパスを指定すると良い様子

`venvtest`という名前で設定する場合
python3 -m venv ~/venvtest

有効化

source ~/venvtest/bin/activate

有効化したら、ここで環境構築する。requirements.txtを使う場合は以下の通り。

pip3 install -r requirements.txt

終了

deactivate

削除

python -m venv --clear ~/venvtest

非常に便利!

参考

venv --- 仮想環境の作成
venv: Python 仮想環境管理

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