Adam Playford
Adam Playford

Reputation: 286

How to direct tkinter to look elsewhere for Tcl/Tk library (to dodge broken library without reinstalling)

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

Upvotes: 4

Views: 1437

Answers (1)

Noah Medling
Noah Medling

Reputation: 4669

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.

Upvotes: 1

Related Questions