Install python with custom tk-tcl installation
derekathomas at gmail.com
Tue Dec 18 04:47:46 CET 2012
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 with a custom installation of tk and tcl (https://github.com/mxcl/homebrew/pull/16626). However, this breaks because homebrew installs tk and tcl in separate directories and then soft-links them to /usr/local/lib. When I install python with this method, it breaks tkinter with the following error:
>>> import Tkinter; root = Tkinter.Tk()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
line 1685, in __init__
self.tk = _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 installation without 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 you in advance.
More information about the Python-list