Python 2.6.3 and finding init.tcl

S

Shawn Wheatley

I'm trying to troubleshoot a bug in VirtualEnv, but in order to do so
I need to better understand how Python initializes Tkinter.

Setup:
Python 2.6.3 on Windows 7 & Windows XP SP3

Problem:
There is a file called init.tcl that gets loaded when first executing
a Tkinter statement. The file is held in the root of the Python folder
in another folder called "tcl"

C:\Python26\tcl\init.tcl

VirtualEnv does not copy this folder; instead it adds the core libs
folders to the Python path. When running Python from a VirtualEnv,
Tkinter statements fail stating that the init.tcl file can't be found.
The strange thing is that the location of the init.tcl file is not
listed in the expected list of locations. As an experiment, I renamed
the "tcl" folder in C:\Python26 to "tcl2" and tried to run
Tkinter._test(). Here is the results:

Python 2.6.3 (r263rc1:75186, Oct 2 2009, 20:40:30) [MSC v.1500 32 bit
(Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\lib-tk\Tkinter.py", line 3749, in _test
root = Tk()
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1643, in __init__
self.tk = _tkinter.create(screenName, baseName, className,
interactive, want
objects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following
directories:
C:/Python26/lib/tcl8.5 C:/lib/tcl8.5 C:/lib/tcl8.5 C:/library C:/
library C:/
tcl8.5.2/library C:/tcl8.5.2/library



This probably means that Tcl wasn't installed properly.

Note that "C:/Python26/tcl" is not in this list. Renaming "tcl2" back
to "tcl" resolves the problem, but it still doesn't explain to me why
Python is looking in that location in the first place. Can anyone shed
some light on how Python/Tkinter initialization works?

Shawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top