Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

python - tkinter program compiles with cx_Freeze but program will not launch

I'm trying to create an executable following this tutorial

https://github.com/anthony-tuininga/cx_Freeze/tree/master/cx_Freeze/samples/Tkinter

After some tweaking I'm able to compile the project but when i click the .exe the mouse loading animation fires but nothing ever loads. This questions has been asked previously but was never resolved.

Where to start looking in the code when your .exe doesn't work after cx_freeze?

My app file

from tkinter import *
from tkinter import messagebox

root = Tk()
root.title('Button')
print("something")
new = messagebox.showinfo("Title", "A tk messagebox")
root.mainloop()

my setup.py

import sys
from cx_Freeze import setup, Executable

base = None
if sys.platform == 'win32':
    base = 'Win32GUI'

executables = [
    Executable('SimpleTkApp.py', base=base)
]

setup(name='simple_Tkinter',
      version='0.1',
      description='Sample cx_Freeze Tkinter script',
      executables= [Executable("SimpleTkApp.py", base=base)])

Also I have been manually adding the TCL/TK libraries

set TK_LIBRARY=C:...k8.6  etc

My configuration: python 3.7, cx_Freeze 5.1.1

Any help would be greatly appreciated, I don't even know where to start on this one.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After trying an even simpler hello world example writing to the console (which also failed) I stumbled across the culprit.

What could be the reason for fatal python error:initfsencoding:unable to load the file system codec?

After updating my freezer.py file with the code found here and using the setup.py provided by jpeg, my example app worked. Thank you both for your swift response.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...