Running server error: "ImportError: No module named 'django'" in OS - X
Running server error: "ImportError: No module named 'django'" in OS - X
我正在尝试启动我的第一个 Django 项目。我安装了 virtualenv 和 运行 Django 1.8.5。当我在我的 virtualenv 中 运行 pip freeze
我得到:
Django==1.8.5
wheel==0.24.0
然后我 CD 进入我的项目 运行 python manage.py runserver
并得到一个错误:
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django'
我打开了我的 manage.py
文件,它包含:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "trydjango18.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
点数列表:
Django (1.8.5)
pip (7.1.2)
setuptools (18.2)
wheel (0.24.0)
我尝试启动多个项目,都给出相同的错误。我尝试过使用和不使用 virtualenv(Django 也在全球范围内安装)都无济于事。我做了很多研究,但没有找到解决我的问题的任何答案。
EDIT 第一次创建新的 virtualenv 和 运行ning source bin/activate
时,我收到以下消息:
/Users/master/Desktop/testdjango/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
首先,你也可以试试这个命令。
python3 manage.py runserver
根据我的经验,我认为你的问题是某些包没有匹配 reason.so ,最好检查文档,如果你做对了每件事。请检查 Django 官方网站。
我有很多使用 OS-X 的经验。因为我在UBUNTU 14工作。04.This一些例子我安装了Django.you可以参考它。
我会成功的,使用下面的方法安装tutorials.I建议您也参考一下并重新安装。
=====================回复你的评论====================
我知道,您的计算机同时安装了 python 2.x 和 python 3.x。
默认 运行 python 2.x。创建虚拟环境时,默认为 python 2.x。所以,你应该在创建虚拟 environment.As 时指定 python 版本 我记得 Django 1.8 不支持 python 2.x。我想现在,你收到了一些答复。
我正在尝试启动我的第一个 Django 项目。我安装了 virtualenv 和 运行 Django 1.8.5。当我在我的 virtualenv 中 运行 pip freeze
我得到:
Django==1.8.5
wheel==0.24.0
然后我 CD 进入我的项目 运行 python manage.py runserver
并得到一个错误:
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django'
我打开了我的 manage.py
文件,它包含:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "trydjango18.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
点数列表:
Django (1.8.5)
pip (7.1.2)
setuptools (18.2)
wheel (0.24.0)
我尝试启动多个项目,都给出相同的错误。我尝试过使用和不使用 virtualenv(Django 也在全球范围内安装)都无济于事。我做了很多研究,但没有找到解决我的问题的任何答案。
EDIT 第一次创建新的 virtualenv 和 运行ning source bin/activate
时,我收到以下消息:
/Users/master/Desktop/testdjango/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
首先,你也可以试试这个命令。
python3 manage.py runserver
根据我的经验,我认为你的问题是某些包没有匹配 reason.so ,最好检查文档,如果你做对了每件事。请检查 Django 官方网站。
我有很多使用 OS-X 的经验。因为我在UBUNTU 14工作。04.This一些例子我安装了Django.you可以参考它。
我会成功的,使用下面的方法安装tutorials.I建议您也参考一下并重新安装。
=====================回复你的评论====================
我知道,您的计算机同时安装了 python 2.x 和 python 3.x。 默认 运行 python 2.x。创建虚拟环境时,默认为 python 2.x。所以,你应该在创建虚拟 environment.As 时指定 python 版本 我记得 Django 1.8 不支持 python 2.x。我想现在,你收到了一些答复。