python ImageTk.PhotoImage - segfault

懵懂的女人 提交于 2020-01-01 04:28:27

问题


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

回答1:


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.




回答2:


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.




回答3:


Now fixed under

Enthought Canopy Python 2.7.6 | 64-bit | (default, Apr 11 2014, 11:55:30) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.


来源:https://stackoverflow.com/questions/9142786/python-imagetk-photoimage-segfault

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!