Python 2.7, tkinter problem on OSX


J

Julien Pauty

Dear list,

Last version of my software relies on ttk. Under windows and linux
this is fine. But, OSX users are facing problems (I don't have access
to a Mac myself for testing...). Those with OSX 10.6 can run the
program. It seems that OSX 8.6 ships with Tk8.5.

People with OSX 8.5 cannot run the app. I told them to install python
2.7 which seems to be the first version on OSX to ship with Tk8.5.
However, the program still does not run. I asked a person to launch a
python 2.7 interpreter and try to import tkinter. This is an excerpt
of the output:

  from Tkinter import *
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/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.7/lib/python2.7/lib-dynload/_tkinter.so,
2): no suitable image found.  Did find:
        /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so:
no matching architecture in universal wrapper

Full log is there: http://pastebin.com/vky8FbrP

I asked a person to simply open a python2.7 shell and import Tkinter.
He got the same error.

All of this is executed with Python 2.7rc1. Archives that are on the
ftp of python.org.

I have seen this bug http://bugs.python.org/issue9045, which is
related, but deals with the specificities if OSX 64bit.

Can this problem be solved by installing Active TK 8.5 for OSX ?

Anybody knows what is the good combination of installer / libraries to
install to run a ttk application on OSX 8.5 ? Ideally, I would like to
document the setup procedure for 8.5 users.

Cheers,

Julien
 
Ad

Advertisements

K

Kevin Walzer

There has been a lot of traffic on the MacPython list about this--see
the list archives.
 
J

Jeff Hobbs

Last version of my software relies on ttk. Under windows and linux
this is fine. But, OSX users are facing problems (I don't have access
to a Mac myself for testing...). Those with OSX 10.6 can run the
program. It seems that OSX 8.6 ships with Tk8.5.

People with OSX 8.5 cannot run the app. I told them to install python
2.7 which seems to be the first version on OSX to ship with Tk8.5.
However, the program still does not run. I asked a person to launch a
python 2.7 interpreter and try to import tkinter. This is an excerpt
of the output:

  from Tkinter import *
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/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.7/lib/python2.7/lib-dynload/_tkinter.so,
2): no suitable image found.  Did find:
        /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so:
no matching architecture in universal wrapper

Full log is there:http://pastebin.com/vky8FbrP

I asked a person to simply open a python2.7 shell and import Tkinter.
He got the same error.

All of this is executed with Python 2.7rc1. Archives that are on the
ftp of python.org.

I have seen this bughttp://bugs.python.org/issue9045, which is
related, but deals with the specificities if OSX 64bit.

Can this problem be solved by installing Active TK 8.5 for OSX ?

Anybody knows what is the good combination of installer / libraries to
install to run a ttk application on OSX 8.5 ? Ideally, I would like to
document the setup procedure for 8.5 users.

The OS X equation is confuzzulating due to version and API changes in
Mac OS X. Let's review ...

OS X 10.5 ships Tcl/Tk 8.4 built 32-bit only i386+ppc using Carbon.
OS X 10.6 ships Tcl/Tk 8.5 built 32/64 i386+x86_64 using Cocoa.

The Cocoa port of Tk was necessary for 64-bit support, as Apple never
did supply the promised 64-bit Carbon. Tk 8.5 has Cocoa as an option,
and it is default in Tk 8.6.

ActiveTcl 8.5 still ships as 32-bit i386+ppc Carbon because going to
Cocoa also means you have to drop OS X 10.4 support (out of curiousity
- does anyone care about OS X 10.4 anymore that isn't stuck on what's
already installed?). 8.5 plans to do so later this year (leaving
behind our OS X 10.4 brethren to older versions). ActiveTcl 8.6 (Tcl/
Tk 8.6 is in beta) already ships i386+x86_64 Cocoa.

Now there is the issue that Tkinter links to a specific version of Tcl/
Tk. I am currently working on a patch that will remove this
limitation (making the binary Tk version independent).

So what do you do?

Well, it depends on what mix you are trying to make. The easiest is
to just run
arch -i386 python2.7
and then it will find the compatible i386 Tk. The next release of
ActivePython 2.7 (which is building i386+x86_64) will have the Tk
version independence, so it could work with core Tk or AT 8.6, or 8.5
in 32-bit mode.

Less confuzzulated?

Jeff
 
Ad

Advertisements

N

Ned Deily

Also happens with python3.1 and OSX 10.6.8

import tkinter #yields:


Traceback (most recent call last):
File "imptk.py", line 1, in <module>
import tkinter
File
"/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/tkinter/__i
nit__.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/3.1/lib/python3.1/lib-dyn
load/_tkinter.so, 2): no suitable image found. Did find:

/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib-dynload/_t
kinter.so: mach-o, but wrong architecture

What version of python3.1 did you install? This does not happen with
the most recent Python 3.1.x's installed by the python.org installers.
There were a number of changes included in Python 3.2 (and 2.7) to
better support building on Mac OS X 10.6 where 64-bit executables are
preferred. If you build your own Python 3.1 on 10.6, you will need to
tweak the build, probably the easiest thing is to only build 32-bit
only. But Python 3.1 is already in security-fix-only mode: best to move
on to Python 3.2 which does not have these issues. See also:

http://www.python.org/download/mac/tcltk/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top