python - Django 没有名为 django.core.management 的模块

标签 python django manage.py

我能够使用 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/

相关文章:

python - Flask SQLAlchemy update_on

python - 当两个外键指向同一个表时如何使用工厂男孩

python - Electron 问题运行manage.py运行服务器

python - Django 1.8.2 和 dumpdata 的 simplejson 错误

django - 外键作为 Django 1.5 可配置用户模型上的必填字段,createsuperuser 表示 : AttributeError: 'NoneType' object has no attribute '_state'

python - 如何正确扩展 Pandas 数据框?

python - PyMC3 的安装问题

Python 括号内的正则表达式

python - Django 部署最佳实践

django - Django Model中的抽象继承,导致MAX递归深度错误