1

我能够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 或编辑任何源代码,因为昨天一切正常。我不明白发生了什么。

4

2 回答 2

3

site-packages您可能有 Django,但您使用的 Python 版本在其文件夹中没有 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.7site-packages文件夹中有 Django,但在 Python 3 上没有,它在我的 then.xml 中找不到任何django模块PYTHONPATH

于 2014-05-18T11:19:06.533 回答
0

卸载 django 并重新安装。

那可能会解决问题。

于 2014-05-18T04:39:07.820 回答