【发布时间】:2023-01-08 01:09:41
【问题描述】:
我在 Python 的第一天,正在尝试将 SciPy 导入到项目中。我通过 pip install 在 ElementaryOS(一个 Ubuntu 衍生产品)上安装了它。我已经通过以下方式验证了它的存在:
$ python
>>> help("modules")
我得到的确切错误是:
导入“scipy”无法解析 Pylance(reportMissingImports)
在搜索此错误时,我发现:
Import could not be resolved/could not be resolved from source Pylance in VS Code using Python 3.9.2 on Windows 10 Powershell——接受的答案都指向一个项目特定的
.env文件。我没有这样的项目结构,对我来说也不需要这样的项目结构。A github issue——这个问题以“它自己修复了”结束
当我运行我的程序时,我在控制台中没有收到任何错误。并查找“Pylance”,它似乎是 Microsoft 产品。我怀疑 VSCode 无法正确检查。可能是因为
pip在它不期望的地方安装了一些东西。这是我的猜测,但我们将不胜感激任何帮助。
编辑:按照缺失路径的想法,我找到了这篇文章——How do I get into the environment VS Code is using for pylance?
将路径添加到可以找到我的模块的位置没有产生任何结果,但我不确定格式是否正确。也许它需要 glob 语法(例如路径/**/*)
【问题讨论】:
标签: python visual-studio-code pylance