Setting up pythonpath in OS X

Jean-Luc Neptune picture Jean-Luc Neptune · Nov 2, 2013 · Viewed 14.3k times · Source

A new PHP developer here trying to learn Python/Django using the "Tango With Django" tutorial.

I'm up to section 2.2.2 where I have to set up the pythonpath and I'm having the following problem:

When I type the following in the terminal: echo $pythonpath I get a blank line instead of the correct path.

I followed the troubleshooting steps and found where the site-packages directory is: Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

Per their instructions I updated my .bashrc file so it looks like this now:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PYTHONPATH=$PYTHONPATH:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

For a reason I don't understand I'm still getting a blank line when I echo $pythonpath.

Because I was having difficulty getting the pythonpath set up I skipped it, but then had problems installing Setuptools, Pip, and Django.

Can anyone tell me what I'm doing wrong? Any resources I can look at beside Tango with Django?

Answer

synthesizerpatel picture synthesizerpatel · Nov 2, 2013

2 issues I can see -

  1. $pythonpath and $PYTHONPATH are different. You want $PYTHONPATH. You will never use the lower-case version $pythonpath for anything, everything Python will 'respond' to will be in uppercase (by default)

  2. By default, $PYTHONPATH is empty and only necessary to add additional paths to beyond the defaults. To see the default list you can run this command in a shell:

    python -c 'import sys;print sys.path'
    

More than likely, the path you want will be in that list.