use*_*202 2 python django python-3.x
我通常在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?
Run Code Online (Sandbox Code Playgroud)
Sud*_*aka 13
尝试使用
python -m pip install django
Run Code Online (Sandbox Code Playgroud)
据我所知,这是最安全的方式
我遇到了同样的问题,请确保您激活了virtualenv,因为一旦关闭cmd,它便不再被激活:
env\Scripts\activate 在cmd中
现在,cmd应该具有(env)如下所示: (env) c:\users\user\PROJECT\..
现在您可以输入: python manage.py runserver
| 归档时间: |
|
| 查看次数: |
27203 次 |
| 最近记录: |