2015-08-13 19 views
6

「TKApplication兩個實現」我使用的是Mac OS X的約塞米蒂10.10.1,我已經安裝使用pip install matplotlib.matplotlib不能在OS X中,錯誤的工作

我想一個簡單的應用程序,如下matplotlib。

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

python應用程序運行並顯示窗口,但沒有任何圖形。命令行給我一個錯誤說:

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. 

我該如何選擇其中一個?

回答

3

我有同樣的問題,所以我的解決方案是不能快速解決問題後不使用Tk的後端。基於我在尋找解決方案時發現的多個線程使用Anaconda時,看起來像是一個週期性問題。

我用這個來找到可用的後端

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

然後添加以下到~/.matplotlib/matplotlibrc使用的Qt4後端

backend:Qt4Agg 
+0

這個解決方案並不爲我工作。 –