Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tkinter cannot find Tcl/Tk on Mac OS X #48267

Closed
fzero mannequin opened this issue Oct 2, 2008 · 27 comments
Closed

Tkinter cannot find Tcl/Tk on Mac OS X #48267

fzero mannequin opened this issue Oct 2, 2008 · 27 comments
Assignees
Labels
build The build process and cross-build OS-mac topic-installation topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@fzero
Copy link
Mannequin

fzero mannequin commented Oct 2, 2008

BPO 4017
Nosy @ronaldoussoren, @benjaminp, @ned-deily, @naufraghi

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/ronaldoussoren'
closed_at = <Date 2008-12-20.22:06:45.297>
created_at = <Date 2008-10-02.15:16:29.478>
labels = ['OS-mac', 'expert-tkinter', 'build', 'expert-installation', 'type-crash']
title = 'Tkinter cannot find Tcl/Tk on Mac OS X'
updated_at = <Date 2009-07-08.06:15:40.911>
user = 'https://bugs.python.org/fzero'

bugs.python.org fields:

activity = <Date 2009-07-08.06:15:40.911>
actor = 'ronaldoussoren'
assignee = 'ronaldoussoren'
closed = True
closed_date = <Date 2008-12-20.22:06:45.297>
closer = 'benjamin.peterson'
components = ['Build', 'Installation', 'macOS', 'Tkinter']
creation = <Date 2008-10-02.15:16:29.478>
creator = 'fzero'
dependencies = []
files = []
hgrepos = []
issue_num = 4017
keywords = []
message_count = 27.0
messages = ['74166', '74221', '74341', '74342', '74440', '74544', '74663', '74722', '74764', '74765', '74838', '74840', '74893', '74981', '75148', '76047', '76101', '77016', '78034', '78036', '78051', '78068', '78077', '78129', '90091', '90249', '90251']
nosy_count = 18.0
nosy_names = ['beazley', 'reowen', 'ronaldoussoren', 'kjohnson', 'wordtech', 'benjamin.peterson', 'ned.deily', 'naufraghi', 'fzero', 'ohmi', 'tommusic', 'Watchman', 'donbraffitt', 'mtsch', 'andreb', 'TJ', 'malkarouri', 'keflavich']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue4017'
versions = ['Python 2.6']

@fzero
Copy link
Mannequin Author

fzero mannequin commented Oct 2, 2008

I've just installed Python 2.6 on Mac OS X 10.5.5 and IDLE won't start.
IDLE 2.5 still works fine.

Here's the traceback:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/idle",
line 3, in <module>
    from idlelib.PyShell import main
  File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/idlelib/PyShell.py",
line 14, in <module>
    import macosxSupport
  File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/idlelib/macosxSupport.py",
line 6, in <module>
    import Tkinter
  File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/Tkinter.py",
line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError:
dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so,
2): Library not loaded: /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl
  Referenced from:
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
  Reason: image not found

@fzero fzero mannequin added topic-IDLE type-crash A hard crash of the interpreter, possibly with a core dump labels Oct 2, 2008
@ohmi
Copy link
Mannequin

ohmi mannequin commented Oct 3, 2008

Installing tcl 8.5 from activestate gets rid of that error but then the
following happens on my pretty clean iMac:

Traceback (most recent call last):
  File "/usr/local/bin/idle", line 5, in <module>
    main()
  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/idlelib
/PyShell.py", line 1382, in main
    root = Tk(className="Idle")
  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-
tk/Tkinter.py", line 1645, in __init__
    self._loadtk()
  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-
tk/Tkinter.py", line 1659, in _loadtk
    % (_tkinter.TK_VERSION, tk_version)
RuntimeError: tk.h version (8.4) doesn't match libtk.a version (8.5)

@benjaminp
Copy link
Contributor

I suspect this is my fault for linking the libraries incorrectly as I
built the installer.

@tebeka
Copy link
Mannequin

tebeka mannequin commented Oct 5, 2008

FWIW, installing MacPorts tcl and tk (8.5.4) didn't help

@njw23
Copy link
Mannequin

njw23 mannequin commented Oct 7, 2008

I asked a slightly different question (related to tkinter in general on
OS 10.4.11), but the symptoms were remarkably similar - perhaps the
solution is as well?

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1114b05318a5507e/a7c269e62b4f0434#a7c269e62b4f0434

Worth a try?

@leoofborg
Copy link
Mannequin

leoofborg mannequin commented Oct 8, 2008

Hello. First time here, beginner at Python. I have verified that the
Google tip link in the previous to fix IDLE works for me. Post in question:

**
[Kevin's post of 6.Oct, 02:58]
You can avoid this problem by building Python yourself and putting
/Library/Frameworks first on the search path for Tcl/Tk. Look in
setup.py in the source code, around line 1438 (in the
'detect_tkinter_darwin' function), and either comment out
/System/Library or put it underneath /Library/Frameworks. This is what
the official build from Python.org should do--look first in
/Library/Frameworks and then fall back on /System/Library/Frameworks.
I'm not sure why it doesn't.

**

In setup.py, I simply put /Library/Frameworks/ first as outlined above,
and then did a config-make-install of the Framework version of Python.
IDLE now does not silently fail now, but runs as 'expected'.

-Leo Marihart
Python Newb,
Somewhat more experienced shell guy

@naufraghi
Copy link
Mannequin

naufraghi mannequin commented Oct 12, 2008

I have the same error as in msg74221
RuntimeError: tk.h version (8.4) doesn't match libtk.a version (8.5)

Some workaround not involving a full rebuild?

@Watchman
Copy link
Mannequin

Watchman mannequin commented Oct 14, 2008

Aloha!

I followed the suggestions in msg74544 by Leo M and can confirm that
IDLE starts as OK.

*BUT* when I try to import Tkinter I get:

>>> import Tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/Tkinter.py",
line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError:
dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so,
2): Library not loaded: /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl
  Referenced from:
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so

It seems the fix is not 100%

@donbraffitt
Copy link
Mannequin

donbraffitt mannequin commented Oct 14, 2008

I've just installed Python 2.6 on Mac OS X 10.5.5 and IDLE won't start.

I have the same problem with Python 2.6 IDLE on Mac OS X 10.4.11.

@njw23
Copy link
Mannequin

njw23 mannequin commented Oct 14, 2008

If you look in /Library/Frameworks/Tcl.framework/Versions/, what's
there? How about in /Library/Frameworks/Tcl.framework/Versions/8.5/?

@donbraffitt
Copy link
Mannequin

donbraffitt mannequin commented Oct 16, 2008

ITEC-MBP-15087:~ dbraffitt$ cd /Library/Frameworks/Tcl.framework/
-bash: cd: /Library/Frameworks/Tcl.framework/: No such file or directory

  • Don

@njw23
Copy link
Mannequin

njw23 mannequin commented Oct 16, 2008

Do you know if you have tcl/tk somewhere else? Otherwise, I think you
need to install it. You can get the source from Sourceforge, or I think
you can get it from Activestate.

http://tcl.sourceforge.net/

@mtsch
Copy link
Mannequin

mtsch mannequin commented Oct 17, 2008

There are two symptoms here, each caused by a different bug.
Neither is specific to IDLE; they have to do with Tkinter recognizing
the correct Tcl/Tk installation at build time and run time.

Bug 1: The Python 2.6 binary installer appears (judging from the error
message) to have been built against a Tcl installation in
/Library/Frameworks/Tcl.framework. Mac OS X (10.4.11 and I assume
Leopard as well) comes with Tcl/Tk, installed in
/System/Library/Frameworks, but there will be no
/Library/Frameworks/Tcl.framework unless you install Tcl/Tk on your own
(but read on before doing so).

Symptom 1: Hence, the error about not being able to find
/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl. This symptom should
not manifest if either a) you install Tcl/Tk 8.5 on your own, or b) you
build Python from the source (so that it finds the pre-installed Tcl in
/System/Library).

Bug 2: The Python source distribution (both 2.5.2 and 2.6; I have not
checked earlier versions) searches for Tcl and Tk in the wrong order, as
pointed out in the comp.lang.python post referenced in msg74440 and
msg74544.

In Mac OS X's standard search order for frameworks, /Library/Frameworks
comes before /System/Library/Frameworks (see the ld and dyld man pages:
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/
ld.1.html and
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/
dyld.1.html), whereas the setup.py script in the Python source
distribution tries /System/Library/Frameworks/Tcl.framework before
/Library/Frameworks/Tcl.framework (and same for Tk.framework).

Symptom 2: This causes a problem _only_ when you have a separately
installed version of Tcl (e.g. 8.5).
Python's setup.py script finds the Tk installation in
/System/Library/Frameworks/Tk.framework (version 8.4) and uses its
headers, whereas the linker (being part of Mac OS X) chooses the Tk
dynamic library in /Library/Frameworks/Tk.framework (version 8.5 if
that's what you installed). (I suspect the linker records the Tcl and Tk
installations (or versions) found at build time.) Hence the error
message about Tk version mismatch.

If you are affected by both of these bugs, Tkinter will not work whether
or not you install Tcl 8.5 in /Library/Frameworks.

I believe the setup.py script ought to be corrected (as per the post
cited in msg74544). I do not know of an easy fix for existing Python
installations that are affected by this, other than rebuilding Python.

@mtsch mtsch mannequin added build The build process and cross-build topic-installation OS-mac topic-tkinter and removed topic-IDLE labels Oct 17, 2008
@mtsch mtsch mannequin changed the title IDLE 2.6 broken on OSX (Leopard) Tkinter cannot find Tcl/Tk on Mac OS X Oct 17, 2008
@andreb
Copy link
Mannequin

andreb mannequin commented Oct 19, 2008

Per instructions in the helpful post outlining the Library search order,
I downloaded and installed AquaTk 8.5.4, then I downloaded
Python-2.6.tar.gz source, ran ./configure --enable-framework, sudo make
build, sudo make install.

IDLE appears to be working well so far. Also the Python interactive
interpreter appears to be working. Except that whenever I do an import
<module> I get a Bus Error and the Python interpreter crashes.
This appears randomly, but no less than the second import <module>
statement I type one after the other. It is interesting to note that the
interactive prompt in the IDLE does not have this problem. Only the
command line (e.g. Terminal) interactive interpreter does, as well as
IPython.

Following is the crash report shown by the Apple Crash Reporter.
Hopefully someone can make sense of it, as I can't (I am not a hardcore
programmer, unfortunately.)

-------------------------- CRASH REPORT ----------------------------
Parent Process: bash [766]

Date/Time: 2008-10-19 20:11:18.643 +0200
OS Version: Mac OS X 10.5.5 (9F33)
Report Version: 6

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread: 0

Thread 0 Crashed:
0 readline.so 0x000bba3c call_readline + 732
1 org.python.python 0x001d43ae PyOS_Readline + 254
2 org.python.python 0x001d5ba0 tok_nextc + 64
3 org.python.python 0x001d6425 PyTokenizer_Get + 101
4 org.python.python 0x001d0da0 parsetok + 256
5 org.python.python 0x002b0942 PyRun_InteractiveOneFlags
+ 306
6 org.python.python 0x002b0c83 PyRun_InteractiveLoopFlags
+ 99
7 org.python.python 0x002b1549 PyRun_AnyFileExFlags + 185
8 org.python.python 0x002c2506 Py_Main + 3046
9 org.python.python.app 0x00001f7b 0x1000 + 3963
10 org.python.python.app 0x00001ea9 0x1000 + 3753

Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x00000000 ebx: 0x000bb76b ecx: 0xbfffeff8 edx: 0x00417ea0
edi: 0x004291d0 esi: 0x004256d0 ebp: 0xbffff108 esp: 0xbffff020
ss: 0x0000001f efl: 0x00010246 eip: 0x000bba3c cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0x00000000

Binary Images:
0x1000 - 0x1ff5 +org.python.python.app 2.6 (2.6)
<c2196bdf25a197afe6742856fe1a0d2c>
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
0x48000 - 0x48ffc +_functools.so ??? (???)
<29c6937481e9eeb3b02765cca7ccf287>
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_functools.so
0xba000 - 0xbbff1 +readline.so ??? (???)
<0a2a766193b43567110e66bf2231dafa>
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/readline.so
0xc1000 - 0xd7fea libedit.2.dylib ??? (???)
<be5a6f391887bb96bdeeafd443cf19fb> /usr/lib/libedit.2.dylib
0xe2000 - 0xe5ff3 +_collections.so ??? (???)
<b8e1e58e2741f43942d616980ceff543>
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_collections.so
0xeb000 - 0xeefff +operator.so ??? (???)
<fc3afb280fb4a4ac8d2ec1a2fd8c67c6>
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/operator.so
0xf5000 - 0xf6fff +time.so ??? (???)
<fbe4f462c631fcfffa042ab980f367aa>
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/time.so
0x1cf000 - 0x2f5fe3 +org.python.python 2.6.0, (c) 2004-2008 Python
Software Foundation. (2.6.0) <44f73bce7c729a42509bd1761feecc32>
/Library/Frameworks/Python.framework/Versions/2.6/Python
0x8fe00000 - 0x8fe2da53 dyld 96.2 (???)
<7af47d3b00b2268947563c7fa8c59a07> /usr/lib/dyld
0x92778000 - 0x9277ffe9 libgcc_s.1.dylib ??? (???)
<a9ab135a5f81f6e345527df87f51bfc9> /usr/lib/libgcc_s.1.dylib
0x94583000 - 0x94587fff libmathCommon.A.dylib ??? (???)
/usr/lib/system/libmathCommon.A.dylib
0x94a36000 - 0x94b96ff3 libSystem.B.dylib ??? (???)
<a12f397abf2285077b89bd726bff5b18> /usr/lib/libSystem.B.dylib
0x95526000 - 0x95555ff7 libncurses.5.4.dylib ??? (???)
<3b2ac2ca8190942b6b81d2a7012ea859> /usr/lib/libncurses.5.4.dylib
0xffff0000 - 0xffff1780 libSystem.B.dylib ??? (???)
/usr/lib/libSystem.B.dylib

-------------------------------------------------------------------

I have MacPorts installed and also an old Fink installation. Could this
be causing it? I also looked through the README troubleshooting section,
and I did not change the default installation location for the framework
as suggested in the README.

If someone could help I'd be most grateful.

André

@benjaminp
Copy link
Contributor

Assigning to Ronald. I all that needs to be done, it have the installers
built correctly.

@TJ
Copy link
Mannequin

TJ mannequin commented Nov 19, 2008

same here

@beazley
Copy link
Mannequin

beazley mannequin commented Nov 20, 2008

Just a quick comment from the Python training universe--this bug makes it
impossible to use Python 2.6 in any kind of Python teaching environment
where IDLE tends to be used a lot. I'm having to tell students to stick
with Python-2.5.2.

@malkarouri
Copy link
Mannequin

malkarouri mannequin commented Dec 5, 2008

Now that Python 2.6.1 is out, can we expect a new OS X installer built
correctly? I think this is pretty important..

@benjaminp
Copy link
Contributor

I've uploaded a .dmg for 2.6.1 to
http://www.python.org/ftp/python/2.6.1/. Could you please test it?

@Watchman
Copy link
Mannequin

Watchman mannequin commented Dec 18, 2008

I downloaded the newly built 2.6.1 dmg and can confirm that, at least
for me:

(1) import Tkinter works.
(2) Starting IDLE works.

It looks like we have a winner, good job Benjamin!

@donbraffitt
Copy link
Mannequin

donbraffitt mannequin commented Dec 19, 2008

I've uploaded a .dmg for 2.6.1 to
http://www.python.org/ftp/python/2.6.1/. Could you please test it?

I installed the 2.6.1 .dmg on Mac OS X 10.5.5, and IDLE once again works
fine.

  • Don

@malkarouri
Copy link
Mannequin

malkarouri mannequin commented Dec 19, 2008

2008/12/18 Benjamin Peterson <report@bugs.python.org>:

Benjamin Peterson <musiccomposition@gmail.com> added the comment:

I've uploaded a .dmg for 2.6.1 to
http://www.python.org/ftp/python/2.6.1/. Could you please test it?

Just to confirm, I have installed the package in OS X 10.4.11, and
Tkinter and Idle work fine.

Many Thanks.

@ohmi
Copy link
Mannequin

ohmi mannequin commented Dec 19, 2008

Installed on 10.5.6, IDLE ran correctly.
Nicely done.

@benjaminp
Copy link
Contributor

Ok. Thanks for testing! I've added the installers to the website.

@keflavich
Copy link
Mannequin

keflavich mannequin commented Jul 3, 2009

Although this is an old & closed error, I'm still running in to it.

I am trying to compile & install 64 bit python with Tk/Tcl support on
Mac OS X 10.5.7.

I have installed 64-bit Tcl/Tk:
$ file /Library/Frameworks/Tk.framework/Versions/8.5/Tk
/Library/Frameworks/Tk.framework/Versions/8.5/Tk: Mach-O universal
binary with 3 architectures
/Library/Frameworks/Tk.framework/Versions/8.5/Tk (for architecture
ppc7400): Mach-O dynamically linked shared library ppc
/Library/Frameworks/Tk.framework/Versions/8.5/Tk (for architecture
i386): Mach-O dynamically linked shared library i386
/Library/Frameworks/Tk.framework/Versions/8.5/Tk (for architecture
x86_64): Mach-O 64-bit dynamically linked shared library x86_64
$ file /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl
/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl: Mach-O universal
binary with 3 architectures
/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (for architecture
ppc7400): Mach-O dynamically linked shared library ppc
/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (for architecture
i386): Mach-O dynamically linked shared library i386
/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (for architecture
x86_64): Mach-O 64-bit dynamically linked shared library x86_64

Everything that _tkinter.so links to appears to be 64-bit capable:
$ otool -L
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so:
/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl
(compatibility version 8.5.0, current version 8.5.7)
/Library/Frameworks/Tk.framework/Versions/8.5/Tk (compatibility
version 8.5.0, current version 8.5.7)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0,
current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 111.0.0)

But somehow _tkinter.so doesn't have x86_64 support:
$ file
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so:
Mach-O universal binary with 2 architectures
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
(for architecture i386): Mach-O bundle i386
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
(for architecture ppc7400): Mach-O bundle ppc

How can I make tkinter work with 64 bit Tcl/Tk?

@ned-deily
Copy link
Member

@keflavich: To include 64-bit support for Tcl/Tk on OSX, you'll need to
modify python's setup.py file. Search down for
"All existing framework builds of Tcl/Tk don't support 64-bit"
around line 1500 in 2.6; there is explicit code there to prevent tkinter
from attempting to link with x86_64 and ppc64 libraries.

@ronaldoussoren
Copy link
Contributor

keflavich: Please open a new issue for the problem you are running in, it
is a completely seperate issue than the one you appended your message to.

Where can I download a 64-bit capable version of Tcl/Tk?

BTW. The correct fix would be to add a probe to setup.py that detects if
Tcl/Tk was build with 64-bit support or not.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build OS-mac topic-installation topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

3 participants