VSCode:Import [包] could not be resolved in Pylance【Import “torch” could not be resolved Pylance】
在VS Code中编写python文件时,import自定义module报错 “could not be resolved Pylance(reportMissingImports)”。
这是因为Pylance未找到自定义模块的地址,可以通过在settings.json文件中添加extraPaths来解决:
1.通过Shift+Ctrl+P打开设置栏,输入settings后找到Perference: Open Settings (JSON)
2.打开settings.json文件后添加下面的代码进去:
"python.analysis.extraPaths": [
"./src", // 自定义模块的相对路径,可多个,可绝对路径
"./modules"
]
</
还没有评论,来说两句吧...