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
fr
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
I know I created the bounty, but I got impatient, decided to investigate, and now I've got something that worked for me. I have a very similar python example to yours, which pretty much does nothing other than try to use Tkinter to display an image passed on the command line, like so:
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
What's happening is that the binary file, ~/anaconda/envs/py35/lib/python3.5/site-packages/PIL/_imagingtk.so
has been linked to a framework, and not the Tcl/Tk libs in the env. You can see this by using otool
to see the linking setup:
(py35)
I try to conduct my own investigation of this problem (in my case that was problem with matplotlib)
osx-tk.patch
and was placed in ~/anaconda/pkgs/matplotlib-1.5.1-np111py35_0/info/recipe/
Found osx-tk.patch
sources into GitHub
After reading the patch and Conda documentation i became finally convinced about wrong package installation, and i remember, that i used pip
for matplotlib installation!
I deleted old package with pip
and install new one with conda install matplotlib
command
Brief summary:
Using pip
package manager with conda environment, i messed my dependencies, because conda may using special recipes, that point installer how to install package correctly in conda virtual environment
Ultra-Brief summary:
Delete package fully with dependencies and install it again with conda package manager (use rebinding only in difficult cases)