Python Forum
[Tkinter] Problem with tkinter when creating .exe file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Problem with tkinter when creating .exe file
I'm currently attempting to take one of my projects and turn it into a .exe file with cxfreeze. Unfortunately I've run into a problem I just cant seem to figure out, I'm hoping maybe someone can tell me what I'm doing wrong here?

So here's the thing...

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "testproject1",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("Structured", base=base)])
This is my setup file that I use to start the whole process. Both this file and my project lies in the root venv folder which also contains the actual python installation and all modules I have ever used.

I use "python" to initialize the building of the new file. Everything goes through, no issues so far...

When the whole process is done I navigate to the "build" file which gets written to the venv folder and inside that folder lies the new .exe file.

Here's the confusing part.

When I launch it i get the following error.

Traceback (most recent call last):
Line 37, in run exec(code, {__name__':'__main__})
File "Structured" line 3, in <module>
ModuleNotFoundError: No module named 'tkinter'

Why is it not finding the tkinter module? I can run the "structured map" file just fine with tkinter imported and it will find it, I have also checked stack overflow and done quite a bit of research but can't find any solution.

Any help is appreciated :)
(Feb-26-2020, 07:24 PM)Jan_97 Wrote: Why is it not finding the tkinter module?
Are you surprised given that on line #5 you explicitly tell it to exclude tkinter?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Ooooof. I am so emberrased. I suppose I suffer too much from tunnel vision when I work on stuff I'm not familiar with. That was the issue. It's ok now, thank you so much.

Possibly Related Threads…
Thread Author Replies Views Last Post
  [TKINTER] Problems creating directories in a selected path Vulera 2 296 Aug-10-2021, 06:38 PM
Last Post: Vulera
  Python3 tkinter radiobutton problem Nick_tkinter 14 1,298 Feb-15-2021, 11:01 PM
Last Post: Nick_tkinter
  tkinter python button position problem Nick_tkinter 3 952 Jan-31-2021, 05:15 AM
Last Post: deanhystad
  [Tkinter] ClockIn/Out tkinter problem Maryan 2 706 Oct-12-2020, 03:42 AM
Last Post: joe_momma
  tkinter| listbox.insert problem Maryan 3 961 Sep-29-2020, 05:34 PM
Last Post: Yoriz
  Tkinter problem DPaul 6 1,452 May-28-2020, 03:40 PM
Last Post: DPaul
  [Tkinter] Tkinter custom widget styling and creating custom theme karolp 6 2,133 May-06-2020, 06:11 PM
Last Post: karolp
  Creating and destroying dynamic labels in Tkinter MarcusRoberts 1 1,612 May-02-2020, 06:49 PM
Last Post: Yoriz
  [Tkinter] Tkinter - I need to read file excel from GUI app to script file johnjh 0 6,059 Apr-17-2020, 08:14 PM
Last Post: johnjh
  [Tkinter] Tkinter - I have problem after import varaible or function from aGUI to script johnjh 2 1,026 Apr-17-2020, 08:12 PM
Last Post: johnjh

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020