Skip to content

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

Closed

Description

@fzero
mannequin
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']

Activity

  1. fzero commented on Oct 2, 2008

    fzeromannequin
    MannequinAuthor

    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
  2. added
    type-crash
    on Oct 2, 2008
  3. ohmi commented on Oct 3, 2008

    ohmimannequin
    Mannequin

    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)
  4. benjaminp commented on Oct 5, 2008

    @benjaminp
    Contributor

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

  5. tebeka commented on Oct 5, 2008

    tebekamannequin
    Mannequin

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

  6. njw23 commented on Oct 7, 2008

    njw23mannequin
    Mannequin

    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?

  7. leoofborg commented on Oct 8, 2008

    leoofborgmannequin
    Mannequin

    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

  8. naufraghi commented on Oct 12, 2008

    naufraghimannequin
    Mannequin

    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?

  9. Watchman commented on Oct 14, 2008

    Watchmanmannequin
    Mannequin

    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%

  10. donbraffitt commented on Oct 14, 2008

    donbraffittmannequin
    Mannequin

    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.

  11. njw23 commented on Oct 14, 2008

    njw23mannequin
    Mannequin

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

  12. donbraffitt commented on Oct 16, 2008

    donbraffittmannequin
    Mannequin

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

    • Don
  13. njw23 commented on Oct 16, 2008

    njw23mannequin
    Mannequin

    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/

  14. mtsch commented on Oct 17, 2008

    mtschmannequin
    Mannequin

    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.

  15. 8 remaining items

  16. TJ commented on Nov 19, 2008

    TJmannequin
    Mannequin

    same here

  17. beazley commented on Nov 20, 2008

    beazleymannequin
    Mannequin

    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.

  18. malkarouri commented on Dec 5, 2008

    malkarourimannequin
    Mannequin

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

  19. benjaminp commented on Dec 18, 2008

    @benjaminp
    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?

  20. Watchman commented on Dec 18, 2008

    Watchmanmannequin
    Mannequin

    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!

  21. donbraffitt commented on Dec 19, 2008

    donbraffittmannequin
    Mannequin

    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
  22. malkarouri commented on Dec 19, 2008

    malkarourimannequin
    Mannequin

    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.

  23. ohmi commented on Dec 19, 2008

    ohmimannequin
    Mannequin

    Installed on 10.5.6, IDLE ran correctly.
    Nicely done.

  24. benjaminp commented on Dec 20, 2008

    @benjaminp
    Contributor

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

  25. keflavich commented on Jul 3, 2009

    keflavichmannequin
    Mannequin

    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?

  26. ned-deily commented on Jul 8, 2009

    @ned-deily
    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.

  27. ronaldoussoren commented on Jul 8, 2009

    @ronaldoussoren
    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.

  28. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

OS-macbuildtopic-installationtopic-tkintertype-crash

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions