Rohan K. Rohan K. - 3 months ago 18
Python Question

Py2exe, Tkinter, and Setup File Problems?

I just finished creating a python program in 2.7 and I converted it to a

.exe
with
py2exe
.

Everything works fine when I run the converted executable file in the folder I placed it in with all of the images in it. After converting the python program to
.exe
, I proceeded to creating a
setup
file for it. I added all of the files associated with my project including
tkinter
in the
setup
file. I added pretty much everything that let me run the executable.

Once I finished creating the
setup
file, I opened it. I went through everything and finished installing it on my system and created a shortcut on my
Desktop
. When I tried to open it, it would not work. Instead of running the program, it tells me to open a log file in its folder in the Program Files. When I open the log file, I noticed an error. How do I fix this?

Error:

Traceback (most recent call last):
File "gui.py", line 10, in <module>
File "Tkinter.pyc", line 1764, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
{C:/Program Files (x86)/lib/tcl8.5} {C:/Program Files (x86)/lib/tcl8.5} C:/lib/tcl8.5 {C:/Program Files (x86)/library} C:/library C:/tcl8.5.15/library C:/tcl8.5.15/library


This probably means that Tcl wasn't installed properly.

Answer

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

I imagine that you are encountering the same issue just without virtualenv the following set the correct paths which can then be included in the application please find 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.