No Module named django.core
I have updated to latest Django version 1.0.2 after uninstalling my old Django version.But now when I run django-admin.py I get the following error. How can I resolve this?
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django\bin\django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core
Solution 1:
I have the same problem on Windows and it seems I've found the problem. I have both 2.7 and 3.x installed. It seems it has something to do with the associate program of .py:
In commandline type:
assoc .py
and the result is:
.py=Python.File
which means .py is associated with Python.File
then I tried this:
ftype Python.File
I got:
Python.File="C:\Python32\python.exe" "%1" %*
which means in commandline .py is associated with my Python 3.2 installation -- and that's why I can't just type "django-admin.py blah blah" to use django.
ALL you need to do is change the association:
ftype Python.File="C:\Python27\python.exe" "%1" %*
then everythong's okay!
Solution 2:
You must make sure that django is in your PYTHONPATH.
To test, just do a import django
from a python shell. There should be no output:
ActivePython 2.5.1.1 (ActiveState Software Inc.) based on
Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>>
If you installed django via setuptools
(easy_install
, or with the setup.py
included with django), then check in your site-packages
if the .pth
file (easy-install.pth
, django.pth
, ...) point to the correct folder.
HIH.
Solution 3:
You can get around this problem by providing the full path to your django-admin.py file
python c:\python25\scripts\django-admin.py startproject mysite