VS Code Python 当import自定义module时 报错 "could not be resolved"

 

在VS Code中编写python文件时,import自定义module报错 "could not be resolved"。

 

Import "[module]" could not be resolvedPylance (reportMissingImports) 

 

 

https://github.com/microsoft/pylance-release/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings

 

 

解决:

在settings.json文件中添加:

 

"python.analysis.extraPaths": [
    "./src",        // 自定义模块的相对路径,可多个,可绝对路径  
    "./modules"
]

 

posted @ 2020-12-05 16:32  cralor  阅读(15202)  评论(0编辑  收藏  举报