Install python with custom tk-tcl installation


Derek Thomas


I seem to have a problem because it seems Tkinter assumes relative paths for TCL_LIBRARY and TK_LIBRARY.

I am working with the homebrew group to get python27 to install nicely witha custom installation of tk and tcl ( However, this breaks because homebrew installs tk and tcl in separate directories and then soft-links them to /usr/local/lib. When I installpython with this method, it breaks tkinter with the following error:

```Traceback (most recent call last):
File "<stdin>", line 1, in <module>
line 1685, in __init__ = _tkinter.create(screenName, baseName, className, interactive,
wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable tk.tcl in the following directories:

This probably means that tk wasn't installed properly.

It is looking in the wrong library directory for the tk.tcl file, which is in /usr/local/Cellar/tk/8.5.9/lib/tk8.5/tk.tcl . In fact, it is assuming that the tk8.5 lib-directory is installed relative to the tcl8.5 lib-directory which is incorrect. It fails because it cannot find the file in the relative directory.

I can fix this by setting the environment variable TCL_LIBRARY to a path that is relative to a soft-linked tk-library (/usr/local/lib/tcl8.5), but is there someway to set tkinter to search the correct path during installationwithout having to set the environment after installation? I looked in _tkinter.c and tkappinit.c but could not find where it was determining the tcl library.

If you have any advice or thoughts, I would be very appreciative. Thank youin advance.


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