LoginSignup
18
13

More than 5 years have passed since last update.

virtualenvごとにPYTHONPATHを切り替える

Posted at

Python環境をvirtualenvを使って管理している場合に、環境変数PYTHONPATHをvirtualenvごとに切り替える方法です。

virtualenv_home/your_env/bin/activateに以下の2行を追加します。

activate
export OLD_PYTHONPATH=$PYTHONPATH
export PYTHONPATH="/path/to/you/want"

virtualenv_home/your_env/bin/postdeactivateに以下の2行を追加します。

postdeactivate
export PYTHONPATH=$OLD_PYTHONPATH
unset OLD_PYTHONPATH
18
13
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
18
13