0
import PySimpleGUI as psg
abc=psg.Button("hi")
psg.Window("hi",layout=[[abc]]).read()

error: i am having this error

C:\Users\makka\Desktop\coding\Scripts\python.exe C:\Users\makka\Desktop\Coding\Coding\ideas\rough.py 
Traceback (most recent call last):
  File "C:\Users\makka\Desktop\Coding\Coding\ideas\rough.py", line 1, in <module>
    import PySimpleGUI as psg
  File "C:\Users\makka\Desktop\coding\lib\site-packages\PySimpleGUI\__init__.py", line 2, in <module>
    from .PySimpleGUI import *
  File "C:\Users\makka\Desktop\coding\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 163, in <module>
    import random
  File "C:\Users\makka\Desktop\coding\random.py", line 4, in <module>
    [sg.Text("hi")],
AttributeError: partially initialized module 'PySimpleGUI' has no attribute 'Text' (most likely due to a circular import)

Process finished with exit code 1

i was exprecting it to work smoothly

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • 4
    Use a different name than "random" for your file, and don't save your files in the same folder as your Python installation. Don't mess with the Python installation folder at all. – molbdnilo Dec 29 '22 at 12:49
  • The exception information not for the provided code. – Jason Yang Dec 29 '22 at 23:52
  • @JasonYang It is; OP has made the mistake of saving files, including one called "random.py", in Python's root directory. When Python does `import random`, it tries to import that file instead of the library's `random` module. – molbdnilo Dec 30 '22 at 09:40

0 Answers0