Matplotlib cannot work on OS X with the error 'TKApplication implemented in both'

I am using Mac OS X Yosemite 10.10.1, I installed matplotlib using pip install matplotlib.

I tried a simple application as shown below.

 import matplotlib.pyplot as plt plt.plot([1,2,3,4], [1,4,9,16], 'ro') plt.axis([0, 6, 0, 20]) plt.show() 

The python application starts and shows a window, but without a graph. The command line just reported me an error:

 Class TKApplication is implemented in both /Users/xisizhe/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. Class TKMenu is implemented in both /Users/xisizhe/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. Class TKContentView is implemented in both /Users/xisizhe/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. Class TKWindow is implemented in both /Users/xisizhe/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. 

How to choose one of two?

+6
source share
1 answer

I had the same problem, so my solution was simply not to use Tk for the backend after you could not quickly solve the problem. Looks like a recurring issue when using Anaconda based on the many threads I found while looking for a solution.

I used this to find affordable backends.

 python -c "import matplotlib; print matplotlib.rcsetup.all_backends" 

Then the following is added to ~/.matplotlib/matplotlibrc to use the Qt4 backend

 backend:Qt4Agg 
+3
source

All Articles