gpt4 book ai didi

python - Pyright 报告的 "Import could not be resolved"

转载 作者:行者123 更新时间:2023-12-03 13:47:34 26 4
gpt4 key购买 nike

enter image description here

我刚开始使用Pyright .在运行良好的文件上运行它会出现很多错误。

This question类似,但指的是自己的模块。

例如 Import "numpy" could not be resolved .这是什么意思,我该如何解决?

最佳答案

在我的电脑上,我有 3 个 Python,一个来自 Anaconda 的 3.6,以及一个 2.7 和 3.7,它们是普通的 python。来自 this GH issue 的轻推提示,我从 Anaconda 3.6 切换到 3.7,然后再切换回来,问题就消失了。

the python chooser

我认为这是因为您的 .vscode/settings.json (以下是我的),在你改变你的 python 之前没有最后一行,此时,最后一行被放入并且 Pyright 有一些东西要看。

{
"python.linting.enabled": true,
"python.formatting.provider": "black",
"python.pythonPath": "C:\\Users\\ben\\Anaconda3\\python.exe"
}

关于python - Pyright 报告的 "Import could not be resolved",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61052890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com