Visual Studio Code Pylance(报告缺少导入)
python 398
原文标题 :Visual Studio Code Pylance (report Missing Imports )
我不断收到错误“X”无法解决 Pylance(reportMissingImports) [ln 1, Col8]
我实际上是初学者,基本的 youtube“修复”不起作用
- 查看命令托盘…不工作
- 终端 pip install …. 不工作我正在我的工作计算机上运行 Zip 安装,我猜它与目录有关。但我似乎无法弄清楚。左下角显示的python版本是( Pyhton 3.110a7 64-bit(windows store)
回复
我来回复-
Vitor Pereira Barbosa 评论
Pylance 要求您设置 Python PATH:
如果您使用的是 Mac/linux,请使用:
which python3
在 Windows 中:
where python
这样就返回了安装 python 的路径
复制该路径。
转到您的 vscode 并打开 settings.json 文件(CTRL + SHIFT + P,然后在搜索栏中键入“settings.json”)
将以下键添加到 json 文件中
“python.defaultInterpreterPath”:“/Users/YOURUSERNAME/opt/anaconda3/bin/python3”
这只是一个示例,如果您使用的是 Windows,PATH 可能更像“C:/users/YOURUSERNAME/anaconda3/bin/python3”。
以下来自 python for vscode 的文档提供了有关如何为 Visual Studio Code 配置 Python 的更多信息:https://code.visualstudio.com/docs/python/settings-reference
2年前