Printing your Python path

It's very easy to print your Python path within Python but since I can never remember it, I thought I'd write it down:

import sys
print sys.path

On the subject of imports and PYTHONPATH, here is a nicely-written article. Also, since I was having a few complications trying to make my PYTHONPATH working, I thought I'd write my set up (on my Mountain Lion MAC using bash). In my /private/etc/bashrc file or whichever bash startup file you prefer, I wrote:


Note that you should use the full path (no ~ or relative path), since python will not transform the path for you. That's why it did not work for me in the first place. In doubt, go print the sys.path in python and check whether your path is in there and properly written.


Popular Posts