PySimpleGUI 引入後VsCode出現問題提示 “could not be resolved” 解決方案

Yvan發表於2021-07-22

問題描述

使用 pip install 安裝 PySimpleGUI 後,程式碼中 import PySimpleGUI as sg 在VsCode 問題提示中出現 “Import “PySimpleGUI” could not be resolved” ,如圖:

PySimpleGUI 引入後出現問題提示 “Import "PySimpleGUI" could not be resolved” 解決方案

只出現問題提示,程式碼執行正常。分析原因可能是 VsCode 的 pylance 外掛尋找依賴的路徑問題

解決方案

配置 pylance 外掛額外的匯入搜尋解析路徑:
1、在 VsCode 設定中搜尋:python.analysis.extraPaths
2、設定路徑(PySimpleGUI 的安裝路徑)

PySimpleGUI 引入後VsCode出現問題提示 “Import "PySimpleGUI" could not be resolved” 解決方案

配置路徑後問題提示不再顯示,完美解決

PySimpleGUI 引入後VsCode出現問題提示 “Import "PySimpleGUI" could not be resolved” 解決方案

參考文章:github.com/microsoft/pylance-relea...

本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章