Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TK Framework double implementation issue

I am testing out creating a GUI using the Tkinter module. I was trying to add an image to the GUI using PIL. My code looks like this:

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)

When I run this code, I come up with some errors that lead to a segfault.

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

I've looked online and it looks to be an issue with the Tk framework in my Systems library and the other in the anaconda library. However, none of the solutions really seemed to work. Any possible solutions or workarounds?

The issue comes with running ImageTk.Photoimage. If I remove that line of code, there is no issues.

like image 211
Michael Avatar asked Feb 24 '16 04:02

Michael


1 Answers

I did exactly what @cjrh said for _imagetk.so, but instead for _tkinter.so in ~/anaconda/lib/python3.5/lib-dynload/ and it worked great!

cd ~/anaconda/lib/python3.5/lib-dynload

$ install_name_tool -change "/System/Library/Frameworks/Tk.framework/Versions/8.5/Tk" "@rpath/libtk8.5.dylib" _tkinter.so
$ install_name_tool -change "/System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl" "@rpath/libtcl8.5.dylib" _tkinter.so
like image 84
user3064438 Avatar answered Oct 11 '22 03:10

user3064438