Switch PYTHONPATH for each virtualenv

This is a method to switch the environment variable PYTHONPATH for each virtualenv when the Python environment is managed using virtualenv.

Add the following two lines to virtualenv_home / your_env / bin / activate.

activate


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

Add the following two lines to virtualenv_home / your_env / bin / postdeactivate.

postdeactivate


export PYTHONPATH=$OLD_PYTHONPATH
unset OLD_PYTHONPATH

Recommended Posts

Switch PYTHONPATH for each virtualenv
Switch the package to be installed for each environment with poetry
Execute NL-means for each RGB channel
Switch the module to be loaded for each execution environment in Python