Text of discuss.python.org › t › customtkinter-import-bug › 63542 as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Customtkinter import bug? - Python Help - Discussions on Python.org

Customtkinter import bug? Python Help Anixtzer (ani) September 10, 2024, 8:30pm 1 Hey so I was just working with customtkinter yesterday and everything worked fine, I saved the file and went to sleep, This morning i woke up and ran the file and i get this error C:\Users\removed>C:/Users/removed/AppData/Local/Programs/Python/Python312/python.exe c:/Usersremoved/CustomTkInter.py Traceback (most recent call last): File "c:\Users\removed\CustomTkInter.py", line 1, in <module> import customtkinter File "C:\Users\removed\AppData\Local\Programs\Python\Python312\Lib\site-packages\customtkinter\__init__.py", line 5, in <module> from tkinter import Variable, StringVar, IntVar, DoubleVar, BooleanVar ImportError: cannot import name 'Variable' from 'tkinter' (c:\Users\REMOVED\tkinter.py) ( PS i removed my name from the error message that’s why you will see “removed”. ) I’ve tried reinstalling customtkinter and it doesn’t work.

Im not sure what’s happening, Here’s the code if anyone could help me out here! import customtkinter customtkinter.set_appearance_mode("System") customtkinter.set_default_color_theme("green") root = customtkinter.CTk() root.geometry("600x600") def login(): label2 = customtkinter.CTkLabel(master=frame, text="Successfully logged in..") label2.pack(pady=12, padx=10) frame = customtkinter.CTkFrame(master=root) frame.pack(pady=20, padx=60, fill="both", expand=True) label = customtkinter.CTkLabel(master=frame, text="Login System", font=("System", 24)) label.pack(pady=12, padx=10) entry1 = customtkinter.CTkEntry(master=frame, placeholder_text="Username",fg_color="#292828") entry1.pack(pady=12, padx=10) entry2 = customtkinter.CTkEntry(master=frame, placeholder_text="Password", show="*",fg_color="#292828") entry2.pack(pady=12, padx=10) button = customtkinter.CTkButton(master=frame, text="login", command=login) button.pack(pady=12, padx=10) checkbox = customtkinter.CTkCheckBox(master=frame, text="Remember Me") checkbox.pack(pady=12, padx=10) root.mainloop() Ps this doesnt work with anything that uses customtkinter, I removed all the buttons, frames etc and had a blank customtkinter project and i still get this error. cameron (Cameron Simpson) September 10, 2024, 9:06pm 2 This line is the clue: ImportError: cannot import name 'Variable' from 'tkinter' (c:\Users\REMOVED\tkinter.py) It’s talking about your own source file!

Not the stdlib tkinter.py file. Rename your source file so that it does not conflict with the tkinter package name. When you run a script, the directory holding the script is put at the front of the Python module search path. This makes it easy to import other .py files you’ve got in with your script, but also makes your filenames shadow (hide) the stdlib filenames. Anixtzer (ani) September 10, 2024, 9:25pm 3 Rename the source file as in rename the file name from tkinter.py → something else?

If that’s what you meant i tried it and still get an error. Anixtzer (ani) September 10, 2024, 9:28pm 4 EDIT: Sorry it works! I had to run the files through terminal and then try again in the code editor. ( I honestly don’t know why this worked but it did. ) Thanks for helping me!!