Home >Backend Development >Python Tutorial >How to Permanently Add a Directory to PYTHONPATH?

How to Permanently Add a Directory to PYTHONPATH?

Susan Sarandon
Susan SarandonOriginal
2024-12-11 07:52:15376browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn