Tkinter on PyCharm not working
Completed
Hello, I have problem with tkinter on pycharm.
import tkinter
canvas = tkinter.Canvas()
canvas.pack()
Traceback (most recent call last):
File "xxx", line 1, in <module>
import tkinter
File "xxx", line 2, in <module>
canvas = tkinter.Canvas()
AttributeError: partially initialized module 'tkinter' has no attribute 'Canvas' (most likely due to a circular import)
Please sign in to leave a comment.
Do you have modules named tkinter in your project?
They may conflict with the tkinter package.
No
Does the same error appear if you run it from the system terminal with the same interpreter?
no
Where does it navigate if you Ctrl+Click (or Ctrl+B) tkinter in the code?
Does it happen in a new project with a new virtual environment?
I have Windows 10, Pycharm 2019.3.4, Python 3.8.2,
I'm going to "cmd" to make a new folder using "virtualenv graphics ". I'll activate it.
I'll open Pycharm, find my folder there. I will create a new Python file. I will write:
At the top right click on "add configuration" give "+" and select "Python" click on "Script path" and select the file. I'll give "ok" and run.
starts:
Traceback (most recent call last):
File "C:/Users/tomas/Desktop/graphics/tkinter.py", line 1, in <module>
import tkinter
File "C:\Users\tomas\Desktop\graphics\tkinter.py", line 3, in <module>
canvas = tkinter.Canvas()
AttributeError: partially initialized module 'tkinter' has no attribute 'Canvas' (most likely due to a circular import)
So your file is called tkinter.py
Could you rename it and see if it helps?
It work. Thanks you so much.