views:

237

answers:

1

I've written a Python script that uses Tkinter. I want to deploy that script on a handful of computers that are on Mac OS 10.4.11. But that build of MAC OS X seems to have a broken TCL/TK install. Even loading the package gives me:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: dlopen(/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload/_tkinter.so   2): Symbol not found: _tclStubsPtr
Referenced from: /System/Library/Frameworks/Tk.framework/Versions/8.4/Tk
Expected in: /System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl

Reinstalling TCL/TK isn't an option since we're in an office and we'd have to get IT to come to each computer, which would deter people from using the script.

Is there any easy way to direct Tkinter to look elsewhere for the TK/TCL framework? I've downloaded a stand alone version of Tcl/Tk Aqua, but I don't know how to control which framework Tkinter uses...

Thanks for the help.

Adam

+1  A: 

You can change where your system looks for dynamic/shared libraries by altering DYLD_LIBRARY_PATH in your environment before launching Python. You can do this in Terminal like so:

$ DYLD_LIBRARY_PATH=<insert path here>:$DYLD_LIBRARY_PATH python

... or create a wrapper:

#!/bin/sh
export DYLD_LIBRARY_PATH=<insert path here>:$DYLD_LIBRARY_PATH
exec python "$@"

The documentation for DYLD_LIBRARY_PATH can be found on the dyld man page.

Do not set this in your .bashrc or any other profile- or system-wide setting, as it has the potential to cause some nasty problems.

Noah Medling
This helped Python find the library, but now it seems that tkinter doesn't know where to look for the new files. Now I get an error telling me that tkinter "Can't find a usable init.tcl in the following directories," and then lists all the standard Python library directories (and not the path I put in DYLD_LIBRARY_PATH).Does anyone happen to know how to change Tkinter's search path?Thanks so much for the help!
Tim
Maybe set PYTHONPATH too?
Andrew Aylett