我试图python manage.py runserver在我拥有的Django应用程序上运行,但出现此错误:
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
以下是pip freeze | grep -i django显示我确实安装了Django的输出:
pip freeze | grep -i django
Django==1.6.5 django-cached-authentication-middleware==0.2.0 django-cors-headers==1.1.0 django-htmlmin==0.7.0 django-static-precompiler==0.9 djangorestframework==2.3.14
此外,尝试运行会/usr/local/bin/python2.7 manage.py runserver产生相同的错误。
/usr/local/bin/python2.7 manage.py runserver
为了解决我的问题,我在.zprofile中使用了以下行:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages
我正在尝试导入Django,但找不到它,执行上述操作解决了该问题。