No Module named django.core

2020-01-24 11:35发布

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

标签: python django
25条回答
仙女界的扛把子
2楼-- · 2020-01-24 11:59

I'm sure it's related to something incorrect in my setup, but I am having the same problem, and it works properly if I call it thusly

c:\somedir>python c:\Python26\scripts\django-admin.py startproject mysite
查看更多
Rolldiameter
3楼-- · 2020-01-24 11:59

I had the same problem in windows xp. The reason was i installed multiple python versions(2.6,3.2).windows's PATH is set correctly to python26, but the .py file is associated with python32. I want the .py file is associated with python26.To solve it, the easit way is to right click the *.py(such as django-admin.py),choose "open with"->"choose program..."->"Browse..." (select c:\python26\python.ext)->"Ok". Then we can run django-admin.py in the cmd without the need for the expatiatory prefix "c:\python26\lib\site-packages\django\bin".

查看更多
萌系小妹纸
4楼-- · 2020-01-24 11:59

Small quick fix is just to create symlink ln -s $SOMEWHERE/lib/python2.6/site-packages/django/ ./django

查看更多
小情绪 Triste *
5楼-- · 2020-01-24 11:59

I realized this happen because I didn't run python setup.py install. That setup the environment.

查看更多
Explosion°爆炸
6楼-- · 2020-01-24 12:01

This worked for me with bitnami djangostack:

python apps\django\django\bin\django-admin.py startproject mysite
查看更多
小情绪 Triste *
7楼-- · 2020-01-24 12:03

I know that this is an old question, but I just had the same problem, in my case, it was because the I am using virtualenv with django, but .py file extensions in Windows are associated with the main Python installation, so running the django-admin.py are directly from the command prompt causes it run with the main Python installation without django installed.

So, since i dont know if there is any hash pound equivalent in Windows, I worked around this by running python followed by the full path of the django-admin.py, or you can also modify the virtualenv batch script to change the file associations and change it back when you deactivate it (although I am not sure how to do it, as I am not really familiar with batch script).

Hope this helps,

查看更多
登录 后发表回答