13
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

Organization

virtualenvごとにPYTHONPATHを切り替える

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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
13
Help us understand the problem. What are the problem?