I made a single slideshow.py file to display some photo correction with Tkinter widget, it runs perfectly on my windows & linux. To made it run on windows without python and tcl installed, I use py2exe to compile it into a win32 executable, setup.py is simple:
from distutils.core import setup
import py2exe
setup(windows=["slideshow.py"])
Then I run "python setup.py py2exe", it generate a "dist" folder in c:\Users\d2xia\ccm_wa\utils\tfps\, and "tcl", "library.zip", "slideshow.exe" and so on under it.
When I run slideshow.exe it errors:
Traceback (most recent call last):
File "slideshow.py", line 45, in <module>
File "Tkinter.pyc", line 1685, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/Users/d2xia/ccm_wa/utils/tfps/lib/tcl8.5 C:/Users/d2xia/ccm_wa/utils/tfps/lib/tcl8.5 C:/Users/d2xia/ccm_wa/utils/lib/tcl8.5 C:/Users/d2xia/ccm_wa/utils/tfps/library C:/Users/d2xia/ccm_wa/utils/library C:/Users/d2xia/ccm_wa/utils/tcl8.5.11/library C:/Users/d2xia/ccm_wa/tcl8.5.11/library
tcl8.5 and tk8.5 actually resides under the "tcl" folder, but it seems the exe generated by py2exe still looks under "lib" or "library", it seems it doesn't set the correct TCL_LIBRARY and TK_LIBRARY.
Even if I rename the "tcl" to "lib", it still get the same errors.
set TCL_LIBRARY=c:\Users\d2xia\ccm_wa\utils\tfps\dist\tcl\tcl8.5\
set TK_LIBRARY=c:\Users\d2xia\ccm_wa\utils\tfps\dist\tcl\tk8.5\
then slideshow.exe generate some new errors:
c:/Users/d2xia/ccm_wa/utils/tfps/dist/tcl/tcl8.5/init.tcl: version conflict for package "Tcl": have 8.5.11, need exactly 8.5.2
version conflict for package "Tcl": have 8.5.11, need exactly 8.5.2
while executing
"package require -exact Tcl 8.5.2"
(file "c:/Users/d2xia/ccm_wa/utils/tfps/dist/tcl/tcl8.5/init.tcl" line 20)
invoked from within
"source c:/Users/d2xia/ccm_wa/utils/tfps/dist/tcl/tcl8.5/init.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source $tclfile]"
I have Tcl 8.5.11 in C:\apps\git\lib\tcl8.5 and Tcl 8.5.2 in C:\Python27\tcl\tcl8.5 It seems when I run with python, it looks for tcl in python installation path, but py2exe looks a different copy in the git installation path.
So then questions become: 1. How to "assign" a correct tcl8.5 copy to py2exe when create the dist? 2. How to let the generated executable aware of the tcl path in the dist? "tcl" instead of "lib" or "library"