简体   繁体   English

Visual Studio 代码中没有名为“dotenv”的模块

[英]no module named "dotenv" in visual studio code

I have seen this question about 5 times before, I have tried every solution there, I have tried uninstalling python-dotenv, reinstalling it, using pip, pip3, using pip3 -m install..., I don't have "dotenv" (the one without python) by itself, I'm not using a virtual environment, i've tried switching to one and installing it but it still says that there is not module named "dotenv".我之前已经看过这个问题大约 5 次,我在那里尝试了所有解决方案,我尝试卸载 python-dotenv,重新安装它,使用 pip,pip3,使用 pip3 -m install ...,我没有“dotenv” (没有python的那个)本身,我没有使用虚拟环境,我尝试切换到一个并安装它,但它仍然说没有名为“dotenv”的模块。 I've also tried sudo pip3 install python-dotenv, yet I still face the same problem.我也试过 sudo pip3 install python-dotenv,但我仍然面临同样的问题。 Can someone help me please?有人能帮助我吗?

图片

As you can see, when I try to use dotenv it doesn't work.如您所见,当我尝试使用 dotenv 时,它不起作用。 I'm using flask if anyone wants to know.如果有人想知道,我正在使用 flask。

Here is what the use looks like:这是使用的样子: 图片

Based on the information you provide, please refer to the following:根据您提供的信息,请参考以下内容:

  1. The location where the module is installed is not the python environment used by the current VS Code terminal.模块安装的位置不是当前VS Code终端使用的python环境。

    Please use the command " python --version " or " pip --version " to check whether the environment used by the VS Code terminal is the same as the one displayed in the lower left corner of VS Code:请使用命令“ python --version ”或“ pip --version ”检查VS Code终端使用的环境是否与VS Code左下角显示的环境相同:

    在此处输入图像描述

    (If their results are not the same, please use the shortcut key Ctrl+Shift+` to open a new VS Code terminal, and it will automatically enter the selected environment. If they are still different, please put the required python first in the python environment variable outside VS Code, and then reopen VS Code. ) (如果结果不一样,请用快捷键Ctrl+Shift+`打开一个新的VS Code终端,它会自动进入选择的环境。如果还是不一样,请将需要的python先放在python中VS Code 外的环境变量,然后重新打开 VS Code。)

  2. Please find the location of the module installation package ( \lib\site-packages\ ), then move out or delete the folder "dotenv", and then reinstall the module.请找到模块安装package的位置( \lib\site-packages\ ),然后移出或删除文件夹“dotenv”,然后重新安装模块。

    在此处输入图像描述

Check the installation of the module: ( pip show python-dotenv )检查模块的安装:( pip show python-dotenv

在此处输入图像描述

Run:跑:

在此处输入图像描述

Reference: Python environments in VS Code .参考: VS Code 中的 Python 环境

Restarting my machine worked for me.重新启动我的机器对我有用。 I guess the restarting of the python virtual environment did it.我猜python虚拟环境的重启做到了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ModuleNotFoundError:Visual Studio Code 中没有名为“pyperclip”的模块 - ModuleNotFoundError: No module named 'pyperclip' in Visual Studio Code “没有名为 PIL 的模块”Visual Studio 代码错误 - 'No module named PIL' Visual Studio Code Error 没有名为“numpy”的模块:Visual Studio Code - No module named 'numpy': Visual Studio Code moduleNotFoundError:没有在 Visual Studio 代码中命名的模块 - moduleNotFoundError: No module named in visual studio code Visual Studio Code ModuleNotFoundError:没有名为“_overlapped”的模块 - Visual Studio Code ModuleNotFoundError: No module named '_overlapped' ModuleNotFoundError:Visual Studio Code 中没有名为“pandas”的模块 - ModuleNotFoundError: No module named 'pandas' in Visual Studio Code ModuleNotFoundError:没有名为“dotenv”的模块 - ModuleNotFoundError: No module named 'dotenv' Visual Studio 代码窗口,Python Pandas。 没有名为 pandas 的模块 - Visual Studio Code windows , Python Pandas . No module named pandas ModuleNotFoundError:没有名为“selenium”的模块。 如何从 Visual Studio Code 修复它? - ModuleNotFoundError: No module named 'selenium'. How to fix it from Visual Studio Code? ModuleNotFoundError:Visual Studio 代码中没有名为“cx_Oracle”的模块 - ModuleNotFoundError: No module named 'cx_Oracle' in Visual Studio Code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM