无法运行“python manage.py runserver”

时间:2022-05-05 00:54:29

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. It worked fine in the past, but today when I tried to run the server it gave me the error:

这是一个由其他人编写的项目,我正在为项目添加新功能。我是python和django的新手,所以以前的开发人员帮我设置了环境。它在过去运行良好,但今天当我试图运行服务器它给了我错误:

(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). But I still run

这很奇怪,因为之前的开发人员确实在我的labtop上安装了django(否则我怎么能成功运行服务器)。但我还是跑

pip install django

to install django again. Then it downloaded and installed django successfully. Then I tried to run the server again, then it gave me this error:

再次安装django。然后它成功下载并安装了django。然后我试图再次运行服务器,然后它给了我这个错误:

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. But it is just a possibility, I am not sure whether it has any effects.

我无法弄清楚这一点,非常感谢任何帮助。我能想到导致这个问题的唯一原因可能是我为我的其他项目安装了anaconda。但这只是一种可能性,我不确定它是否有任何影响。

1 个解决方案

#1


1  

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

Naiem Soliman

#1


1  

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

Naiem Soliman