[英]Django:No module named django.core.management
I am a Django newbie and want to explore the power of this famous framework. 我是Django的新手,想要探索这个着名框架的力量。
After all setups I ran 完成所有设置后,我跑了
sudo python manage.py syncdb
, sudo python manage.py syncdb
,
and I get this error 我收到这个错误
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
I use virtualenv and virtualenvwrapper, and I activated my working virtualenv by issuing a workon
command. 我使用virtualenv和virtualenvwrapper,并通过发出workon
命令激活了我的工作virtualenv。
Also, when I ran which python
, I got this: 另外,当我运行which python
,我得到了这个:
/home/myname/Envs/EnvName/bin/python
, /home/myname/Envs/EnvName/bin/python
,
and pip freeze| grep - django
和pip freeze| grep - django
pip freeze| grep - django
returns: pip freeze| grep - django
返回:
Django==1.5.4
django-toolbelt==0.0.1
The first line of my manage.py is #!/usr/bin/env python
. manage.py的第一行是#!/usr/bin/env python
。
Also 也
python2.7 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
gives 给
/home/myname/Envs/EnvName/lib/python2.7/site-packages
and in this directory, I do see a folder named django. 在这个目录中,我看到一个名为django的文件夹。
So I guess I am really stuck, anyone please? 所以我想我真的被卡住了,有人请吗?
This first line its probably making it use your python from /usr/bin/env
. 这第一行可能是它使用/usr/bin/env
python。
You could try two things in this case: 在这种情况下你可以尝试两件事:
1) If you didn't already, you should activate your virtualenv and then install Django: 1)如果你还没有,你应该激活你的virtualenv,然后安装Django:
source /home/myname/Envs/EnvName/bin/activate
pip install django
2) Remove first line of manage.py which I don't thing would be a problem since you are using python manage.py ...
, unless you didn't activated
your virtualenv before. 2)删除manage.py的第一行,因为你使用的是python manage.py ...
,所以我不会有问题,除非你之前没有activated
你的virtualenv。
UPDATE: 更新:
There is really nothing more that what it's saying. 真的没有什么比它说的更多了。 Python couldn't find django, so you just need to activate
(which I think you already did) and pip install django
. Python找不到django,所以你只需要activate
(我认为你已经做过)和pip install django
。
ANOTHER UPDATE: 另一个更新:
Your problem its actually simpler to solve. 你的问题实际上更容易解决。 You are trying sudo python manage.py syncdb
and when you do using sudo you are not accessing python from virtualenv
, so just remove sudo and everything should run. 你正在尝试sudo python manage.py syncdb
,当你使用sudo时,你没有从virtualenv
访问python,所以只需删除sudo,一切都应该运行。
system. 系统。
Maybe you already fix it out. 也许你已经解决了。 But I post this for later fellows. 但我发布这个给后来的研究员。
try: 尝试:
which python sudo which python
after you see the different. 看到不同之后。 you are able to do:(with you env activated: source activate) 你能做到:(你的env激活:源激活)
sudo `which python` manage.py shell sudo`哪个python` manage.py shell
hope helps 希望有所帮助
cheers 干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.