【问题标题】:ModuleNotFoundError: No module named 'django' even if it is installed (vs code)ModuleNotFoundError:即使已安装,也没有名为“django”的模块(与代码相比)
【发布时间】:2022-01-02 02:45:28
【问题描述】:

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

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:\django\project\telusko> & C:/Users/hp/AppData/Local/Programs/Python/Python39/python.exe e:/django/project/telusko/calc/urls.py
Traceback (most recent call last):
  File "e:\django\project\telusko\calc\urls.py", line 1, in <module>
    from django.urls import path
ModuleNotFoundError: No module named 'django'
PS E:\django\project\telusko> 

【问题讨论】:

    标签: python django visual-studio-code django-urls virtual-environment


    【解决方案1】:

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

    python -m pip install Django
    

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2020-11-18
        • 1970-01-01
        • 2023-02-07
        • 2021-06-28
        • 1970-01-01
        • 1970-01-01
        • 2018-08-18
        • 2022-07-06
        • 1970-01-01
        相关资源
        最近更新 更多