简体   繁体   中英

Problems with Tkinter in py2exe

I made aa simple GUI program in python with tkinter and attempted to convert it to an .exe using py2exe. However, I've run into a problem. When I try to run the exe it flashes an error very quickly then disapears. So the best I could do was take a screan shot of the error.

How do I go about fixing this?

替代文字

Edit

Velociraptors, this is my setup file. It's about as basic as it can be. How would I go about integrating init.tcl into the code?

from distutils.core import setup
import py2exe

setup(console=[r'C:\Python26\Random Password Generator.py'])

Does your setup.py script include init.tcl in the data_files option? The py2exe list of options says that's how you should include images and other required data files.

Edit:

Your setup script specifies that your program should be converted to a console exe. If you want a GUI program (which you do, since you're using Tkinter), you need to use the windows option:

setup(windows=[r'C:\Python26\Random Password Generator.py'])

Py2exe should correctly include Tkinter's dependencies. If not, you can manually include init.tcl :

setup(data_files=['C:\Python26\tcl\tcl8.5\init.tcl'],
      windows=[r'C:\Python26\Random Password Generator.py'])

I found a bug on the virutalenv site which suggested the following https://github.com/pypa/virtualenv/issues/93

for windows in your directory "C:\\Environments\\VirtualEnv\\Scripts\\activate.bat" just add which are set to the right path to TCL and TK for your python version

set "TCL_LIBRARY=C:\Python27\tcl\tcl8.5" 
set "TK_LIBRARY=C:\Python27\tcl\tk8.5" 

restart your cmd or shell

I believe that the TCL location have changed from there default ones.

Ensure that tcl is installed in C:\\Users\\splotchy\\lib\\tcl8.5 or C:\\Users\\lib\\tcl8.5 .

If you want to see the error messages for longer, run your program from a command prompt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM