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

How to Permanently Add a Directory to PYTHONPATH?

Susan Sarandon
Release: 2024-12-11 07:52:15
Original
377 people have browsed it

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"
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template