我通常在 PC 上工作,但开始在我的 Mac 上处理项目。我运行 Python 3,当我开始一个新项目时,我执行了以下操作:
- 在主项目文件夹中,安装 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?
原文由 user3088202 发布,翻译遵循 CC BY-SA 4.0 许可协议
尝试使用
据我所知,这是最安全的方式