Python and Django: ImportError: No module named django.core
Python is without a doubt a great language. Django is a great framework. It is just obvious to use them and get your site up and running. So, today, while setting up a new site with “django-admin.py startproject mysite” I’ve run into the “ImportError: No module named django.core” error.
While hunting for a solution on the net, none of them seamed to work, though I knew the problem is most likely just a path issue. See, I’ve installed python with brew in order to receive the 2.7.3 update (MacOS X Mountain Lion ships with 2.7.2 and it doesn’t look like Apple is upgrading it). The issue here is that brew installs everything in the “/usr/local/bin” directly.
Now, you might say, to simply add the “/usr/local/bin/” directory to the Path environment, but the point here is that the “django-admin.py” has the path to set to “#!/usr/bin/python”. In other words, edit the file “django-admin.py” (most likely at /usr/local/bin/) and give it the correct path to python (“”#!/usr/bin/python”).
Voila. Now the utility works as expected. On with coding…