【问题标题】:Could not resolve PyPDF2无法解析 PyPDF2
【发布时间】:2021-12-27 08:32:27
【问题描述】:

当我在 VisualStudioCode 代码编辑器上导入 PyPDF2 并尝试使用 Tkinter 创建 GUI 时向我显示此错误,这是我的第一个 GUI 代码,我仍在学习。我在导入 PyPDF2 时出错。代码是-

                   import tkinter
                   import PyPDF2
                   from PIL import Image, ImageTK
                   
                   root = tkinter.Tk()
                   

它还在 PIL 中显示错误,我无法将它们配置出来: 错误: '''App.py C:\Users____________________\Downloads 2


                    import "PyPDF2 could not be resolved                                                  
                    Pylance(reportMissingImports) [3,8]
                    ⚠ Import could not be resolved from source 
                    Pylance(reportMissingModuleSource) [4,6]

【问题讨论】:

    标签: python visual-studio-code


    【解决方案1】:

    参考Diagnostic Severity RulesreportMissingModuleSource表示

    诊断没有对应源文件的导入。这 当找到类型存根时发生,但模块源文件没有 找到了,说明在使用这个的时候代码运行时可能会失败 执行环境。类型检查将使用类型存根完成。

    简而言之,目前使用的python环境中没有这样的模块。

    选择python解释器后,打开一个新集成终端然后运行pip show PyPDF2。如果您获得详细信息并且它的位置是current interpreter\lib\site-packages,重新加载窗口应该可以解决您的问题。如果没有,请重新安装。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-14
      相关资源
      最近更新 更多