Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permanently add a directory to PYTHONPATH?

Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory to PYTHONPATH?

like image 523
John Howard Avatar asked Aug 04 '10 02:08

John Howard


People also ask

How do I add a directory to a path in Python?

Clicking on the Environment Variables button o​n the bottom right. In the System variables section, selecting the Path variable and clicking on Edit. The next screen will show all the directories that are currently a part of the PATH variable. Clicking on New and entering Python's install directory.

What is the difference between path and Pythonpath?

PYTHONPATH is related to sys. path very closely. PYTHONPATH is an environment variable that you set before running the Python interpreter. PYTHONPATH , if it exists, should contain directories that should be searched for modules when using import .


1 Answers

If you're using bash (on a Mac or GNU/Linux distro), add this to your ~/.bashrc

export PYTHONPATH="${PYTHONPATH}:/my/other/path" 
like image 56
awesomo Avatar answered Sep 29 '22 03:09

awesomo