Trouble With Python Paths and Installing Django From SVN
Just a quick note for others that might have this problem since I wasn’t able to find much information about it. I installed django manually using an svn checkout to /Library/Python/2.6/site-packages/django. On Snow Leopard while trying to get a django site up and running I tried to run manage.py syncdb and I got this error:
ImportError: No module named django.core.management
As it turns out, django — though installed in the right place — wasn’t in my PYTHONPATH so it couldn’t be loaded. You can test this by changing directories to your django project and issuing this command:
python
… which starts the python shell. And then from the shell, type:
import sys
print sys.path
You should get some output like this:

On Mac OS X version 10.6 (Snow Leopard), django gets installed into /Library/Python/2.6/site-packages/django (which you’ll notice is absent from the sys.path output). There are a few ways to fix this. Probably the easiest is to simply add a file named django.pth in /Library/Python/2.6/site-packages/. In this file put the path of the django library:
/Library/Python/2.6/site-packages/django
Save and quit and you should be good to go.
Another approach would be to add django to your PYTHONPATH by adding this to the .profile or .bash_profile file that’s in your home directory:
export PYTHONPATH=/Library/Python/2.6/site-packages/django:$PYTHONPATH
Alternatively, if you’d like to potentially use a different version of django for each project you can symlink the django directory you want to use into your project:
ln -s /Library/Python/2.6/site-packages/django ./django
More info can be found here:
- Python Installation Docs
- Snow Leopard’s Python 2.6 site-packages
- How to install Django on Mac OS X 10.6 Snow Leopard
Find This Article Useful?
Related Articles
About this entry
You’re currently reading “Trouble With Python Paths and Installing Django From SVN,” an entry on MirthLab
- Published:
- Thursday, January 7th, 2010 at 11:07 am
- Author:
- Mark Quezada
- Category:
- Web Development
- Tags:
- django, mac os x, python, pythonpath

No comments
Jump to comment form | comments rss | trackback uri