No Module named django.core


Question

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
1
66
9/8/2013 12:01:04 AM

Accepted Answer

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.

36
11/28/2008 8:40:35 AM

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!


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon