0

I have a decently long program that I have been trying to compile. I have tried py2exe and cx_Freeze, both seem to come up with this problem.

I used the following setup.py file to compile my program:

import sys
from cx_Freeze import setup, Executable

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

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

setup(name='version_3_2',
      version='0.32',
      description='desc',
      executables=executables
      )

From running this using

python setup.py build

The executable is created.

From running the executable, i was given a traceback stating that

TclError: Can't find a usable init.tcl in the following directories:
C:/Python27/build/lib/tcl8.5
and a bunch of other directories

From adding all of the tkinter and tcl files and folers into a couple of those directories i get the next traceback from executing:

C:/Python27/build/lib/tcl8.5/init.tcl: version conflict for package "Tcl":
have 8.5.15, need exactly 8.5.2
version conflict for package "Tcl": have 8.5.15, need exactly 8.5.2
  while executing
"package require -exact Tcl 8.5.2"
  (file "C:/Python27/build/lib/tcl8.5/init.tcl" line 20)
  invoked from within
"source C:/Python27/build/lib/tcl8.5/init.tcl"
  ("uplevel" body line 1)
  invoked from within
"uplevel #0 [list source $tclfile]"

I'm not entirely sure what to do. Several solutions like How to correct TCL_LIBRARY and TK_LIBRARY with py2exe and Py2exe with Tkinter have not worked.

Any Ideas?

Community
  • 1
  • 1
seekjet
  • 28
  • 7

1 Answers1

0

You need to match exactly the libtcl8.5.dll (or whatever the name is on your system) and the init.tcl (and related files) because they are both part of the same Tcl installation. If you change one out, you must change the other as well. How exactly you've mangled your installation I'm not quite sure, but mangled it surely is. Also be aware that in Tcl 8.5 (and before), it's strongly advised to match the Tk version precisely to it as well; we relax this requirement in 8.6 but you're not using that…

(Note that this is different from the way that normal dependencies work in Tcl; typically a program will depend on a minimum API version, not an exact one.)

Since you've got a binary build of 8.5.15 in use, you might as well use the script files for that version too. I suggest getting the Tcl source distribution for 8.5.15 from SourceForge and grabbing the files out of the library directory in there. You probably only need the .tcl files directly in there (especially init.tcl of course!) and not in any of the subdirectories, as the subdirectories are for official add on packages and those aren't so tightly bound to Tcl versions.

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
  • Thanks, this worked perfectly! Moving and changing the files to what they should be managed to do the trick. The main problem was that for some reason half the tcl files were missing, and an unnecessary tcl folder in another area. fixed those and removed unnecessary folder, and it works like a charm. thanks! – seekjet Jun 03 '14 at 06:22