Permanently add a directory to PYTHONPATH
Here add feature to your new directory to the surroundings variable PYTHONPATH, separated by a colon from previous contents therefrom. In any variety of UNIX operating system, you’ll be able to do this in an exceedingly startup script applicable to no matter shell you are victimisation (.profile or no matter, counting on your favorite shell) with a command that, again, depends on the shell in question; in Windows, you’ll be able to bed through the system GUI for the aim.
superuser.com could also be an improved place to raise any, i.e. for a lot of details if you would like specifics regarding the way to enrich associate degree surroundings variable in your chosen platform and shell, since it is not extremely a programming question intrinsically.
Rather of manipulating PYTHONPATH you’ll be able to conjointly produce a path configuration file. initial establish within which directory Python searches for this information:
python -m website --user-site
For some reason this does not appear to figure in Python 2.7. There you’ll be able to use:
python -c 'import website; site._script()' --user-site
Then produce a .pth enter that directory containing the trail you would like to feature (create the directory if it does not exist).
# find directory SITEDIR=$(python -m website --user-site) # create if it does not exist mkdir -p "$SITEDIR" # create new .pth file with our path echo "$HOME/foo/bar" > "$SITEDIR/somelib.pth