Search code examples
pythonattributeerrorpysimplegui

How could I get away with AttributeError while tryning to run my program powered by PySimpleGUI in Python?


Well, I first downloaded the PySimpleGUI module by using pip install PySimpleGUI in terminal.

Afterwards, I got a sequence of multiple errors.

I attempted this:

import PySimpleGUI as sg

label = sg.Text('Type in a to-do')
input_box = sg.InputText(tooltip='Enter to-do')

window = sg.Window('My to-do app', layout=[[label, input_box]])
window.read()
window.close()

I was expecting As you see, the label and input_box were succesfully intrepreted by Python

However, it resulted in error:

Traceback (most recent call last):
  File "c:\Users\User\Desktop\New_Python_Stuff\PySimpleGUI.py", line 1, in <module>
    import PySimpleGUI as sg
  File "c:\Users\User\Desktop\New_Python_Stuff\PySimpleGUI.py", line 3, in <module>
    label = sg.Text('Type in a to-do')
AttributeError: partially initialized module 'PySimpleGUI' has no attribute 'Text' (most likely due to a circular import)

Solution

  • Ohh that's my bad I've mistakenly named the program 'PySimpleGUI' and I am 100 sure that because of it the error reminds me of 'initialized module'.