[Tkinter-discuss] Segfault in Image.PhotoImage on OS X

Russell E. Owen rowen at uw.edu
Fri Apr 27 22:10:55 CEST 2012

In article 
<CALcZXRHT=M2=bfDVU_if1TN2M4Ktfw1U6HYjORchTwK5C8Se0Q at mail.gmail.com>,
 Marc Culler <marc.culler at gmail.com> wrote:

> This was reported here in February, but no debugging information was
> provided by the reporter:
> http://stackoverflow.com/questions/9142786/python-imagetk-photoimage-segfault
> <view-source:http://stackoverflow.com/questions/9142786/python-imagetk-photoim
> age-segfault>
> I can explain the nature of the problem, but I don't know how to fix
> it correctly.
> I am using the standard x86_64 Python 2.7.2 package from python.org and I 
> have
> installed Active State Tcl/Tk 8.11.
> When I tried using easy_install to install PIL it would not load,
> claiming that _imaging.so
> did not exist.  In fact, it existed but was only a thin i386
> executable. So I compiled
> Imaging-1.1.7 with
>  export CFLAGS='-arch i386 -arch x86_64'
> and
>  export TCL_ROOT=/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl
> I was then able to load the module.  However, the following code
> produced a segfault:
> import Image
> import ImageTk
> import Tkinter
> W = Tkinter.Tk()
> Im = Image.open('test_image.jpg')
> x = ImageTk.PhotoImage(Im)
> The crash occurs in Tk_GetImageMasterData.  More importantly, though,
> the crash was
> preceded by the following messages:
> objc[36554]: Class TKApplication is implemented in both
> /Library/Frameworks/Tk.framework/Versions/8.5/Tk and
> /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the
> two will be used. Which one is undefined.
> objc[36554]: Class TKMenu is implemented in both
> /Library/Frameworks/Tk.framework/Versions/8.5/Tk and
> /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the
> two will be used. Which one is undefined.

This sounds like a know bug with XCode 3.2.6 described here:

The problem is an incorrect link to /Library/Frameworks. The following 
fix suggested by "Nertzius" worked for me:

cd /Developer/SDKs/MacOSX10.6.sdk/Library;
sudo mv Frameworks Frameworks-orig
sudo mv Frameworks-orig/Frameworks .
sudo rm -rf Frameworks-orig

By the way, you can get an unofficial Mac binary installer for PIL, 
built for python.org python here:

-- Russell

More information about the Tkinter-discuss mailing list