Home >Backend Development >Python Tutorial >How to Permanently Add a Directory to PYTHONPATH?
How to Persist Directory in PYTHONPATH
Sys.path.append is a temporary modification to the PYTHONPATH environment variable, and the changes are lost upon restarting the Python interpreter. To permanently add a directory to PYTHONPATH, consider the following solution:
For bash users (on Mac or GNU/Linux systems), add the following line to your ~/.bashrc file:
export PYTHONPATH="${PYTHONPATH}:/my/other/path"
This will permanently add the specified directory to the PYTHONPATH variable.
The above is the detailed content of How to Permanently Add a Directory to PYTHONPATH?. For more information, please follow other related articles on the PHP Chinese website!