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"
]

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM