我正在测试使用 Tkinter 模块创建 GUI。我试图使用 PIL 将图像添加到 GUI。我的代码如下所示:
import Tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
root.title('background image')
imfile = "foo.png"
im = Image.open(imfile)
im1 = ImageTk.PhotoImage(im)
当我运行这段代码时,我发现了一些导致段错误的错误。
objc[5431]: Class TKApplication is implemented in both/Users/sykeoh/anaconda/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[5431]: Class TKMenu is implemented in both /Users/sykeoh/anaconda/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[5431]: Class TKContentView is implemented in both /Users/sykeoh/anaconda/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[5431]: Class TKWindow is implemented in both /Users/sykeoh/anaconda/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
Segmentation fault: 11
我在网上查了一下,似乎是我的 Systems 库中的 Tk 框架和 anaconda 库中的另一个框架存在问题。然而,这些解决方案似乎都没有真正起作用。有什么可能的解决方案或解决方法吗?
运行 ImageTk.Photoimage 时会出现此问题。如果我删除那行代码,就不会有问题。
我知道我创造了赏金,但我变得不耐烦,决定进行调查,现在我得到了一些对我有用的东西。我有一个与你的非常相似的 python 示例,它除了尝试使用 Tkinter 显示在命令行上传递的图像之外几乎什么也不做,如下所示:
calebhattingh $ python imageview.py a.jpg
objc[84696]: Class TKApplication is implemented in both /Users/calebhattingh/anaconda/envs/py35/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[84696]: Class TKMenu is implemented in both /Users/calebhattingh/anaconda/envs/py35/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[84696]: Class TKContentView is implemented in both /Users/calebhattingh/anaconda/envs/py35/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[84696]: Class TKWindow is implemented in both /Users/calebhattingh/anaconda/envs/py35/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
Segmentation fault: 11
发生的事情是binary file, ~/anaconda/envs/py35/lib/python3.5/site-packages/PIL/_imagingtk.so
已链接到框架,而不是环境中的 Tcl/Tk 库。你可以通过使用来看到这一点otool
查看链接设置:
(py35)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)