【发布时间】:2022-01-07 05:56:43
【问题描述】:
当我第一次运行服务器时,一切都很好,项目运行正常。但是几天后我再次运行服务器时,它给了我一个错误
Traceback (most recent call last): File "C:\Users\Admin\Desktop\Django Project\first\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\Admin\Desktop\Django Project\first\manage.py", line 22, in <module> main() File "C:\Users\Admin\Desktop\Django Project\first\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?
具体来说,我在 Windows 10 上,使用 VS Code 作为我的 IDE(我没有设置任何虚拟环境)。 已安装 Django 版本 - 3.2.9 已安装 Python 版本 - 3.10.0 已安装 PIP 版本 - 21.2.3
这是我的环境变量的屏幕截图 [
【问题讨论】:
-
你安装了 django 吗?您可以使用 pip freeze 进行检查
-
在你的路径中,有
Django Project。您需要将其更改为不包含空格。 -
pip show django的结果是什么? -
您可以尝试重新安装它吗?
-
@Yerycs 我不明白。请您详细说明一下吗?
标签: python django visual-studio-code