Permanently add a directory to PYTHONPATH?

John Howard picture John Howard · Aug 4, 2010 · Viewed 663.2k times · Source

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?

Answer

awesomo picture awesomo · Aug 4, 2010

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

export PYTHONPATH="${PYTHONPATH}:/my/other/path"