How to add the path to Python for Linux forever?

I know that there are several solutions on the Internet, but some of them relate to windows, some relate to an environment variable, etc.

What is the best way?

+4
source share
2 answers

Find your sites directory and create a new file called myproj.pth

Inside this file, put each directory you want to add, one per line:

  / home / myuser / svn-repos / myproject
 / home / myuser / svn-repos / SomeOtherProject

Python loads *.pth every time it starts and imports all the paths in each of these files.

On Ubuntu, this directory can often be found in /usr/local/lib/python2.6/dist-packages/

+11
source

I personally just define PYTHONPATH in ~/.bashrc , what is the "best" approach for? I think it’s hard to answer (or rather, there is no right answer). It depends.

+1
source

All Articles