我能够使用 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
我没有卸载 django 或编辑任何源代码,因为昨天一切正常。我不明白发生了什么。
最佳答案
您可能拥有 Django,但您使用的 Python 版本在其 site-packages
文件夹中没有 Django。检查您正在使用哪个版本以及您在哪个版本上安装了 Django。从昨天开始,您可能已经更改了默认的 Python 解释器:
$ python
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core.management import execute_from_command_line
>>>
[...]
$ python3
Python 3.2.3 (default, Jul 23 2012, 16:48:24)
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core.management import execute_from_command_line
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django.core.management
这里,我的 Python 2.7 site-packages
文件夹中有 Django,但 Python 3 上没有,并且在我的 PYTHONPATH< 中找不到任何
那么。django
模块
关于python - Django 没有名为 django.core.management 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23718529/