[英]Cannot run “python manage.py runserver”
This is a project written by other people and I am working on adding new features to the project.这是一个由其他人编写的项目,我正在为该项目添加新功能。 I am new to python and django so the previous developer helped me setup the environment.我是 python 和 django 的新手,所以以前的开发人员帮助我设置了环境。 It worked fine in the past, but today when I tried to run the server it gave me the error:过去它运行良好,但是今天当我尝试运行服务器时,它给了我错误:
(genienv)Xueyangs-MacBook-Pro:userservice xueyangli$ python manage.py runserver
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
This is weird because the previous developer did install django on my labtop(otherwise how can I run the server successfully before).这很奇怪,因为以前的开发人员确实在我的labtop 上安装了 django(否则我之前如何成功运行服务器)。 But I still run但我还是跑
pip install django
to install django again.再次安装django。 Then it downloaded and installed django successfully.然后它成功下载并安装了django。 Then I tried to run the server again, then it gave me this error:然后我尝试再次运行服务器,然后它给了我这个错误:
Xueyangs-MacBook-Pro:userservice xueyangli$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/Users/xueyangli/anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/xueyangli/anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Users/xueyangli/anaconda/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/xueyangli/anaconda/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Users/xueyangli/anaconda/lib/python2.7/site-packages/django/apps/config.py", line 87, in create
module = import_module(entry)
File "/Users/xueyangli/anaconda/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named provider
I could not figure this out and would really appreciate any help.我无法弄清楚这一点,非常感谢任何帮助。 The only reason I could think of which cause this problem is probably I installed anaconda for my other project.我能想到导致这个问题的唯一原因可能是我为我的另一个项目安装了 anaconda。 But it is just a possibility, I am not sure whether it has any effects.但这只是一种可能性,我不确定它是否有任何影响。
Please do this请这样做
python -m pip install django --upgrade python -m pip install django --upgrade
make sure you have all the required packages installed first and they are listed in the django document确保首先安装了所有必需的软件包,并且它们在 django 文档中列出
Naiem Soliman纳伊姆·索里曼
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.