Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use third party packages in Python. To import all the modules I need to update PYTHONPATH. I read several blogs on it but still I have following questions unanswered.

  1. Is sys.path & PYTHONPATH are same things ? (probably not)

  2. How to see current value of PYTHONPATH (which is something called environmental variable) ?

  3. How to update PYTHONPATH permenently ?

I know I can do sys.path.append('/<PATH>'), but that updates sys.path until you do not exit the Python interpreter.


(I know this but I do not know what is current $PYTHONPATH)

How do I update PYTHONPATH permanently ?

share|improve this question
  1. I'm not into phython, but it seems that the sys.path variable is just an accessor to the system-wide PYTHONPATH variable. If you modify it, the PYTHONPATH variable won't be changed, only the sys.path python variable.
  2. Type into your command prompt: echo $PYTHONPATH If it shows nothing, PYTHONPATH isn't set at all.
  3. Add that export ... line at the end of the .bashrc file of the concerning user's home directory and restart your shell.
share|improve this answer
  1. sys.path contains paths from PYTHONPATH environment variable plus the folder the script was started from. See more info here
  2. echo $PYTHONPATH in a terminal or import os; print os.environ['PYTHONPATH'] (from Python, will work if such a variable was defined)
  3. To set an environment variable for all applications, read this. Add this export PYTHONPATH=$PYTHONPATH:/path/to/some/package to ~/.pam_environment file.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.