【发布时间】:2021-02-04 18:04:52
【问题描述】:
我一直在学习 django 3.x 并设置了所有必要的人员。
我激活了我的虚拟环境并且它可以工作,但是当我尝试运行这个命令时它给了我这个错误:
Traceback (most recent call last):
File "C:\Users\dzhiv\Dev\django-bootcamp\manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\dzhiv\Dev\django-bootcamp\manage.py", line 22, in <module>
main()
File "C:\Users\dzhiv\Dev\django-bootcamp\manage.py", line 13, in main
raise ImportError(
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?
- 我在路径环境中有 python。(如果我没有,cmd 不会显示我 当我输入python时)我创建了虚拟环境(python -m venv。)我 启动 django 项目(django-admin startproject ...)我激活 带有(.\Scripts\activate)的虚拟环境,它可以工作。当我跑 这个(python manage.py createsuperuser)命令我出错了。
所以我在 Windows 10 电脑上,我使用了 powershell 或 VsCode 的终端(我知道)。
我该怎么办?
【问题讨论】:
-
你在虚拟环境中安装
Django了吗? -
你应该激活环境,然后运行
pip install Django。 -
当然先生。我在那里运行了一些 django 命令(django-admin startproject),我确信 django 可以工作。
-
但是
django-admin不是Djangopython 包的一部分。那只是一个构建文件的程序,但它不包含 Python 库。