tcl/tk version confusion with tkinter in Python 2.6, on OS X

Discussion in 'Python' started by njwilson23@gmail.com, Oct 6, 2008.

  1. Guest

    I'm having trouble with tkinter on a new installation of Python (2.6),
    built with the framework option from source that was downloaded from
    python.org. I'm running OS 10.4 on a PowerPC G4.

    The problem first arose when I tried to run matplotlib - it couldn't
    find tcl/tk because it was searching for 8.5, and I had 8.4. I found
    and built tcl/tk 8.5, which led to a new error, reproduced below:

    Traceback (most recent call last):
    File "brownian2.py", line 55, in <module>
    main()
    File "brownian2.py", line 41, in main
    root = Tk()
    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)

    I'm a bit of a neophyte - can anyone tell me how to go about fixing
    this? I've found some information by searching the list and Google,
    but no helpful solutions.

    Thanks,
    Nat
     
    , Oct 6, 2008
    #1
    1. Advertising

  2. Guest

    On Oct 6, 4:48 pm, wrote:
    > I'm having trouble with tkinter on a new installation of Python (2.6),
    > built with the framework option from source that was downloaded from
    > python.org. I'm running OS 10.4 on a PowerPC G4.
    >
    > The problem first arose when I tried to run matplotlib - it couldn't
    > find tcl/tk because it was searching for 8.5, and I had 8.4. I found
    > and built tcl/tk 8.5, which led to a new error, reproduced below:
    >
    > Traceback (most recent call last):
    >   File "brownian2.py", line 55, in <module>
    >     main()
    >   File "brownian2.py", line 41, in main
    >     root = Tk()
    >   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)
    >
    > I'm a bit of a neophyte - can anyone tell me how to go about fixing
    > this? I've found some information by searching the list and Google,
    > but no helpful solutions.
    >
    > Thanks,
    > Nat



    I haven't yet installed Python 2.6, but I've seen this error reported
    here and on the MacPython list.

    Based on what I'm seeing in the error message and in the setup.py file
    in the source code, it appears that Python 2.6 is looking in
    /System/Library/Frameworks for a Tcl/Tk installation rather than in
    /Library/Frameworks, which is second on the list of places to look.
    Tcl/Tk 8.4 comes standard with OS X in 10.4 and 10.5, and it's
    installed
    in /System/Library/Frameworks. The problem is that Python 2.6 seems to
    be linked against Tcl/Tk 8.5--is this correct?--and when it finds Tcl/
    tk
    8.4, it returns an error.

    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.

    Should a bug report be filed against this? If the Mac build of Python
    2.6 consistently looks in /System/Library/Frameworks for Tcl/Tk, it
    won't run Tkinter applications. It makes the build pretty much useless
    for anyone needing it to run Tkinter apps, including Idle. I'd say
    it's
    a showstopper issue.

    --Kevin
     
    , Oct 6, 2008
    #2
    1. Advertising

  3. Marans Guest

    On Oct 6, 5:58 pm, wrote:
    > On Oct 6, 4:48 pm, wrote:
    >
    >
    >
    > > I'm having trouble with tkinter on a new installation of Python (2.6),
    > > built with the framework option from source that was downloaded from
    > > python.org. I'm running OS 10.4 on a PowerPC G4.

    >
    > > The problem first arose when I tried to run matplotlib - it couldn't
    > > find tcl/tk because it was searching for 8.5, and I had 8.4. I found
    > > and built tcl/tk 8.5, which led to a new error, reproduced below:

    >
    > > Traceback (most recent call last):
    > >   File "brownian2.py", line 55, in <module>
    > >     main()
    > >   File "brownian2.py", line 41, in main
    > >     root = Tk()
    > >   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)

    >
    > > I'm a bit of a neophyte - can anyone tell me how to go about fixing
    > > this? I've found some information by searching the list and Google,
    > > but no helpful solutions.

    >
    > > Thanks,
    > > Nat

    >
    > I haven't yet installed Python 2.6, but I've seen this error reported
    > here and on the MacPython list.
    >
    > Based on what I'm seeing in the error message and in the setup.py file
    > in the source code, it appears that Python 2.6 is looking in
    > /System/Library/Frameworks for a Tcl/Tk installation rather than in
    > /Library/Frameworks, which is second on the list of places to look.
    > Tcl/Tk 8.4 comes standard with OS X in 10.4 and 10.5, and it's
    > installed
    > in /System/Library/Frameworks. The problem is that Python 2.6 seems to
    > be linked against Tcl/Tk 8.5--is this correct?--and when it finds Tcl/
    > tk
    > 8.4, it returns an error.
    >
    > 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.
    >
    > Should a bug report be filed against this? If the Mac build of Python
    > 2.6 consistently looks in /System/Library/Frameworks for Tcl/Tk, it
    > won't run Tkinter applications. It makes the build pretty much useless
    > for anyone needing it to run Tkinter apps, including Idle. I'd say
    > it's
    > a showstopper issue.
    >
    > --Kevin


    Worked like a charm for getting Tkinter to work, thanks!

    Seems strange that this is the way it's shipped; wonder if there's a
    good reason?

    Still having trouble with matplotlib, but I suspect that's unrelated,
    and I'll work on it.

    Again, thanks!
     
    Marans, Oct 7, 2008
    #3
  4. Kent Johnson Guest

    On Oct 6, 5:58 pm, wrote:
    > On Oct 6, 4:48 pm, wrote:
    >
    > > I'm having trouble with tkinter on a new installation of Python (2.6),
    > > built with the framework option from source that was downloaded from
    > > python.org. I'm running OS 10.4 on a PowerPC G4.

    >
    > > The problem first arose when I tried to run matplotlib - it couldn't
    > > find tcl/tk because it was searching for 8.5, and I had 8.4.


    I also had this problem. The error message at this point is
    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

    Note that at this point I did have Tk 8.4 installed at
    /System/Library/Frameworks/Tk.framework/Versions/8.4
    and this works fine with Python 2.5, so Python 2.6 seems to be looking
    specifically for Tk 8.5.

    > >I found
    > > and built tcl/tk 8.5, which led to a new error, reproduced below:
    > > RuntimeError: tk.h version (8.4) doesn't match libtk.a version (8.5)


    I installed Tcl/Tk 8.5 from ActiveState and got the same error.

    > Based on what I'm seeing in the error message and in the setup.py file
    > in the source code, it appears that Python 2.6 is looking in
    > /System/Library/Frameworks for a Tcl/Tk installation rather than in
    > /Library/Frameworks, which is second on the list of places to look.
    > Tcl/Tk 8.4 comes standard with OS X in 10.4 and 10.5, and it's
    > installed
    > in /System/Library/Frameworks. The problem is that Python 2.6 seems to
    > be linked against Tcl/Tk 8.5--is this correct?--and when it finds Tcl/
    > tk
    > 8.4, it returns an error.


    I don't think that is quite right. In this second error, I think 8.4
    is the compiled-in version, 8.5 is the version detected at runtime.
    8.4 is the value of _tkinter.TK_VERSION, 8.4 is read from the Tk
    object.

    It looks to me like Python 2.6 is built against Tcl/tk 8.4 but at
    runtime it looks for Tcl/tk 8.5.

    > Should a bug report be filed against this? If the Mac build of Python
    > 2.6 consistently looks in /System/Library/Frameworks for Tcl/Tk, it
    > won't run Tkinter applications. It makes the build pretty much useless
    > for anyone needing it to run Tkinter apps, including Idle. I'd say
    > it's
    > a showstopper issue.


    I think so.

    Kent
     
    Kent Johnson, Oct 7, 2008
    #4
  5. Guest

    , Nov 1, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Adelein and Jeremy
    Replies:
    0
    Views:
    332
    Adelein and Jeremy
    Apr 29, 2004
  2. Replies:
    0
    Views:
    370
  3. V Green
    Replies:
    0
    Views:
    885
    V Green
    Feb 5, 2008
  4. PA Bear [MS MVP]
    Replies:
    0
    Views:
    1,000
    PA Bear [MS MVP]
    Feb 5, 2008
  5. Mumia W.

    Inline::Tcl vs. Inline::Tcl

    Mumia W., Aug 23, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    155
    Mumia W.
    Aug 23, 2006
Loading...

Share This Page