tags:

views:

78

answers:

2

I installed python 2.6 alongside my mac's 2.5.2 version. As soon as I did, python2.6 manage.py runserver failed because it couldn't find django.core.management.

From a shell, import django returns importerror: No module named django.

Why?

+1  A: 

Did you reinstall Django?

This happens when I install side by side versions of Python on Gentoo. Whenever I install a new version, I have to either reinstall the new ones or make a symlink to the old site-packages.

voyager
Rerunning "sudo python setup.py install" was the answer. But I spent about four hours learning that 2.5 is installed in /System/Library/Frameworks/Python.framework/Versions/, while 2.6 is installed in /Library/... (same as above, without the System). Who cares? Well, Django installs to Python's site-packages folder. In 2.5 that's in /Library/Python/2.x/site-packages, separate from the installed Django version. In 2.6, it's in the lib folder under the installed Django version (/Library/Frameworks/Python.framework/Versions/2.6/lib/site-packages). This feels more logical to me.
Alex
A: 

Because each installation of Python uses its own directory to store libraries. On a Mac, they are in /Library/Python/2.x/site-packages/. Presumably you originally installed Django in the 2.5 directory, but it isn't yet in the 2.6 one. You can symlink it there if you want to, or reinstall it using the new version.

Daniel Roseman
Python looks like it's installed in Users/Applications/Python\ 2.6, but that's definitely not the install. That's extra stuff that I don't understand yet. Django indeed needs to be installed in the site-packages folder of any Python version that you're using. The hard thing is that site-packages is in /Library/Python/2.x/site-packages for versions up to Python 2.6. In 2.6 it's in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages.
Alex