Question

I run at a cloned Django repository

python manage.py runserver

I get

Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management

The problem is in my PYTHONPATH according to MacPorts' IRC.

I run

ls -l $(which python)

I get

lrwxr-xr-x  1 root  wheel    68B Jan 29 12:27 /usr/local/bin/python -> ../../../Library/Frameworks/Python.framework/Versions/2.6/bin/python

This command suggests according to krunk that my PATHs are incorrect: /opt/local/... should be before /usr/local/...

However, I am not sure what he means.

My PYTHONPATH in ~/.zshrc is

export PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.6/:$HOME/.python_libraries:

where /opt/local/... is the first PATH as krunk suggests.

I run

which $PYTHONPATH
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/:/Users/Sam/.python_libraries: not found

My PYTHONPATH has something wrong: apparently the /opt/locall/... is not right.

How can you get the PYTHONPATH correct?

Was it helpful?

Solution

Your problem is not with PYTHONPATH, it's with PATH itself -- echo $PATH to see it, export PATH=whatever to change it (you can do that in your ~/.bashrc for example).

You'll see that in your current PATH /usr/local/bin comes before /opt/local/bin -- you need to swap them if you want python to be running from your MacPorts. Alternatively, of course, you can choose to explicitly run /opt/local/bin/python ...

OTHER TIPS

I would recommend not using macports, and install Python using Jesse Noller's instructions at http://jessenoller.com/2009/03/16/so-you-want-to-use-python-on-the-mac/

His instructions assume Bash, but should work the same for zsh.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top