Python 2.6.3 and finding init.tcl

Discussion in 'Python' started by Shawn Wheatley, Oct 15, 2009.

  1. 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.
    >>> import Tkinter
    >>> Tkinter._test()

    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
    Shawn Wheatley, Oct 15, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Cheng
    Replies:
    1
    Views:
    8,205
    Juan T. Llibre
    Feb 24, 2006
  2. Replies:
    1
    Views:
    656
    Jules
    Aug 18, 2005
  3. Jess
    Replies:
    4
    Views:
    438
  4. news.aon.at
    Replies:
    11
    Views:
    640
    Ian Collins
    Jan 29, 2011
  5. Mumia W.

    Inline::Tcl vs. Inline::Tcl

    Mumia W., Aug 23, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    137
    Mumia W.
    Aug 23, 2006
Loading...

Share This Page