ModuleNotFoundError:即使安装了名为"django"的模块(相对于代码)



我在虚拟环境中安装了django,也激活了虚拟环境,但它仍然显示这些错误python

from django.urls import path

输出

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS E:djangoprojecttelusko> & C:/Users/hp/AppData/Local/Programs/Python/Python39/python.exe e:/django/project/telusko/calc/urls.py
Traceback (most recent call last):
File "e:djangoprojectteluskocalcurls.py", line 1, in <module>
from django.urls import path
ModuleNotFoundError: No module named 'django'
PS E:djangoprojecttelusko> 

在激活的环境中尝试pip-freeze命令。如果django不存在于结果中,请使用以下命令

python -m pip install Django

您已经在虚拟环境中安装了django,但您使用的是全局python环境:

C:/Users/hp/AppData/Local/Programs/Python/Python39/python.exe 

最新更新