Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python ImageTk.PhotoImage - segfault

I am trying to run the following command on a Mac 10.6.8:

Python 2.7.2 |EPD 7.1-2 (64-bit)| (default, Jul 27 2011, 14:50:45) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin

import Image 
import ImageTk
from Tkinter import Tk

window = Tk()
i = Image.open("file.jpg")
photo = ImageTk.PhotoImage(i)
Segmentation fault

I've seen others have had a bus error in this situation. Does anyone know of a bug here or a way round it? I couldn't understand whether http://infohost.nmt.edu/tcc/help/pubs/pil/image-tk.html was relevant. Thanks!

I'm sorry to say the same thing happens even after upgrading EPD:

Python 2.7.2 |EPD 7.2-2 (64-bit)| (default, Sep  7 2011, 16:31:15) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
like image 255
jtlz2 Avatar asked Feb 04 '12 17:02

jtlz2


2 Answers

If you are not using Apple's Tcl/Tk, try running otool -L on _imagingtk.so to see whether it is looking for its shared libraries in /System/Library. It should be looking in /Library, not /System/Library. If so, you can change the library search path with install_name_tool.

like image 131
Marc Avatar answered Oct 06 '22 04:10

Marc


Have you tried running Mac Python in 32 bit mode?

Look at the Fat Binary:

cd /usr/bin/
file python

I get:

python: Mach-O universal binary with 2 architectures
python (for architecture x86_64):   Mach-O 64-bit executable x86_64
python (for architecture i386): Mach-O executable i386

To try 32 bit mode you would do:

arch -i386 /usr/bin/python

If that works, then it would at least be a workaround.

like image 21
Mark Bennett Avatar answered Oct 06 '22 04:10

Mark Bennett