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?
To set this variable from the Command Prompt, use: set PYTHONPATH=list;of;paths . To set this variable from PowerShell, use: $env:PYTHONPATH='list;of;paths' just before you launch Python.
PATH is an essential environment variable that decides how programs and commands work on macOS. Setting the PATH variable for a program or script allows you to run it from anywhere on the file system without specifying its absolute path.
2 issues I can see -
$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)
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.
For a reason I don't understand I'm still getting a blank line when I echo $pythonpath.
Environment variables are case sensitive. PYTHONPATH
and pythonpath
are different. So:
echo $PYTHONPATH
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