使用Pycharm和Python311无法导入PysimpleGUI

问题描述 投票:0回答:0

使用 Pycharm 和 Python 311,导入 PySimpleGUI 引发错误: AttributeError: partially initialized module 'tkinter' has no attribute 'TclError' (很可能是由于循环导入)

清单如下:

    import numpy as np
    import os
    import matplotlib.pyplot as plt
    import PySimpleGUI as sg


    files2 = os.listdir(pathtest)
    print('pathtest=', pathtest)
    layout = [[sg.Text('Choose Image')],
          [[sg.Combo(files2, key=('-C-'), size=(50, 30))]],
          [sg.Input(key='-F-')],
          [sg.Button('Find'), sg.Exit()]]
    go = True
    window = sg.Window('Face Recognition', layout)
    while go:
        # The Event Loop,pca
        event, values = window.read()
        window.close()
        print(event, values)
        if event == sg.WIN_CLOSED or event == 'Exit':
            go = False
        else:
            run(values,images)
C:\Python311\python.exe C:\Users\mario\Workspace\PythonWorkspace\P_FaceRecognition\main.py 
Traceback (most recent call last):
  File "C:\Users\mario\Workspace\PythonWorkspace\P_FaceRecognition\main.py", line 11, in <module>
    import PySimpleGUI as sg
  File "C:\Python311\Lib\site-packages\PySimpleGUI\__init__.py", line 2, in <module>
    from .PySimpleGUI import *
  File "C:\Python311\Lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 136, in <module>
    import tkinter as tk
  File "C:\Python311\Lib\tkinter\__init__.py", line 38, in <module>
    TclError = tkinter.TclError
               ^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'tkinter' has no attribute 'TclError' (most likely due to a circular import)

Process finished with exit code 1
pycharm pysimplegui
© www.soinside.com 2019 - 2024. All rights reserved.