【发布时间】:2017-01-09 23:23:04
【问题描述】:
我通常在 PC 上工作,但开始在我的 Mac 上处理项目。我运行 Python 3,当我开始一个新项目时,我做了以下事情:
1) 在主项目文件夹中,安装 virtualenv 并激活它。
2) 安装 Django 和 Gunicorn
3) 是否启动了项目
当我尝试 python3 manage.py startapp www 时,我收到一个错误,即无法导入 Django。以下是终端中的内容:
(venv) AB:directory AB$ pip freeze
Django==1.10
gunicorn==19.6.0
(venv) AB:directory AB$ ls
directory manage.py
(venv) AB:directory AB$ python3 manage.py startpap www
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'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
import django
ImportError: No module named 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
【问题讨论】:
-
使用 python3 但正常 pip ?嗯....您是否尝试过使用 pip3 并使用它安装 django ?
-
startpap或startapp? -
@Take_Care_ no 但是当我执行 pip freeze 时,我看到 Django 1.10 安装在 venv 中
-
@DeA startapp 拼错了...同样的结果
-
你用什么命令来创建你的 virtualenv?似乎它基于 Python 2,而不是 3。
标签: python django python-3.x