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
#1
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 map.py", 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 setup.py" 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):
File
"C:\users\owner\desktop\untitled\venv\lib\site-packages\cx_freeze\initscripts\console.py"
Line 37, in run exec(code, {__name__':'__main__})
File "Structured map.py" 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 :)
Reply
#2
(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

Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating a function interrupt button tkinter AnotherSam 2 5,412 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [TKINTER] Problems creating directories in a selected path Vulera 2 2,727 Aug-10-2021, 06:38 PM
Last Post: Vulera
  Python3 tkinter radiobutton problem Nick_tkinter 14 5,828 Feb-15-2021, 11:01 PM
Last Post: Nick_tkinter
  tkinter python button position problem Nick_tkinter 3 3,482 Jan-31-2021, 05:15 AM
Last Post: deanhystad
  [Tkinter] ClockIn/Out tkinter problem Maryan 2 2,161 Oct-12-2020, 03:42 AM
Last Post: joe_momma
  tkinter| listbox.insert problem Maryan 3 3,437 Sep-29-2020, 05:34 PM
Last Post: Yoriz
  Tkinter problem DPaul 6 4,040 May-28-2020, 03:40 PM
Last Post: DPaul
  [Tkinter] Tkinter custom widget styling and creating custom theme karolp 6 4,742 May-06-2020, 06:11 PM
Last Post: karolp
  Creating and destroying dynamic labels in Tkinter MarcusRoberts 1 4,243 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 10,670 Apr-17-2020, 08:14 PM
Last Post: johnjh

Forum Jump:

User Panel Messages

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