[英]I can't import dotenv from python-dotenv
Windows, Visual studio, django. Windows,视觉工作室,django。 I tried to install python-dotenv: https://pypi.org/project/python-dotenv/#getting-started .
我尝试安装 python-dotenv: https://pypi.org/project/python-dotenv/#getting-started 。
But when I want to import this command, I get error: Import "dotenv" could not be resolvedPylancereportMissingImports.但是当我想导入这个命令时,我得到了错误:Import "dotenv" could not be resolvedPylancereportMissingImports。
I made such imports: (venv) PS C:\Users... pip3 install python-dotenv Requirement already satisfied: python-dotenv in c:\users...\venv\lib\site-packages (0.19.0).我做了这样的导入:(venv) PS C:\Users... pip3 install python-dotenv 要求已经满足:c:\users...\venv\lib\site-packages (0.19.0) 中的 python-dotenv。
But import doesn't work.但是导入不起作用。 What can be wrong?
有什么问题?
I solved this issue by adding the Python path to the settings.json file in VScode.我通过将 Python 路径添加到 VScode 中的 settings.json 文件解决了这个问题。 Specifically, my .vscode folder contains "settings.json" where I added:
具体来说,我的 .vscode 文件夹包含我添加的“settings.json”:
"python.pythonPath": "/path/to/python3"
Maybe it helps.也许它有帮助。
如果您有 1 个以上的 Python 版本,请尝试更改您的 Python 版本。我遇到了 3.10.0 的问题,我将其更改为 3.9.6。
I had the same problem.我有同样的问题。 Check if the Python interpreter VSCode is using is the one from your virtual environment (eg
myproject/venv/Scripts/python.exe
).检查 VSCode 正在使用的 Python 解释器是否来自您的虚拟环境(例如
myproject/venv/Scripts/python.exe
)。 You can read more about it on the official VSCode docs .您可以在官方 VSCode 文档中阅读更多相关信息。
I had a similar problem working with the virtual environment.我在使用虚拟环境时遇到了类似的问题。 I found my solution in this link: https://stackoverflow.com/a/59832029/18736200 .
我在这个链接中找到了我的解决方案: https://stackoverflow.com/a/59832029/18736200 。 Everything works fine now
现在一切正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.