1
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の仮想環境 ”venv” の作成・起動・停止の備忘録

Posted at

時々venvを作成してみようと思うことがあるのですが、毎回作成方法を忘れてしまうため、ここに整理しておこうと思います。
私はWindowsユーザーですが、WSL経由でエディタを立ち上げているため、下記コマンドはLinuxの場合になります。

venvの作成方法

python3 -m venv "ディレクトリ名"

・自分が使用したいディレクトリに作成すること。

venvの起動方法

source "ディレクトリ名"/bin/activate

・binとは、venv環境につくられたバイナリファイル。仮想環境のスクリプトやコマンドが保存されている。
・いま自分のいるディレクトリがどこなのかに気を付ける。作成したディレクトリにいる時は、

source bin/activateになる。ここでディレクトリ名を入力するとエラーがでる。

venvの停止方法

deactivate

・仮想環境が壊れることがあるため、作業後はdeactivateを忘れないようにする。

1
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
1
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?