In ~/.bash_profile
file (OS X) I've set PYTHONPATH to point to two folders:
export PYTHONPATH=/Applications/python/common:$PYTHONPATH export PYTHONPATH=/Applications/sitecustomize:$PYTHONPATH
Even while sitecustomize
folder is set on a second line (after /common
) the first path is ignored and I am not able to import any module from the path defined in a first line. What needs to be revised in above syntax to make both folders PYTHONPATHish to Python?
Background. Setting the PYTHONPATH environment variable is an easy way to make Python modules available for import from any directory. This environment variable can list one or more directory paths which contain your own modules. On Windows, multiple paths are separated by semicolons.
PYTHONPATH is an environment variable which you can set to add additional directories where python will look for modules and packages. For most installations, you should not set these variables since they are not needed for Python to run. Python knows where to find its standard library.
Append your paths so there is only one PYTHONPATH.
PYTHONPATH="/Applications/python/common:/Applications/sitecustomize:$PYTHONPATH" export PYTHONPATH
Then source ~/.bash_profile
OR import them into your Python script (this would only work for the script added to):
import sys sys.path.append("/Applications/python/common") sys.path.append("/Applications/sitecustomize")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With