TclError matplotlib 1.5.0 [英] TclError matplotlib 1.5.0
问题描述
使用下面的代码,将生成TclError.
Using the code below, a TclError is generated.
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16], 'ro')
plt.axis([0, 6, 0, 20])
plt.show()
当我在终端中执行我的脚本时,我得到以下信息:
When I execute my script in terminal, I get the following:
/Users/<username>/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:1035: UserWarning: Duplicate key in file "/Users/<username>/.matplotlib/matplotlibrc", line #2
(fname, cnt))
objc[44479]: Class TKApplication is implemented in both /Users/<username>/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[44479]: Class TKMenu is implemented in both /Users/<username>/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[44479]: Class TKContentView is implemented in both /Users/<username>/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[44479]: Class TKWindow is implemented in both /Users/<username>/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.
2016-02-01 20:45:40.991 python[44479:21064918] setCanCycle: is deprecated. Please use setCollectionBehavior instead
2016-02-01 20:45:41.000 python[44479:21064918] setCanCycle: is deprecated. Please use setCollectionBehavior instead
Exception in Tkinter callback
Traceback (most recent call last):
File "/Users/<username>/anaconda/lib/python2.7/lib-tk/Tkinter.py", line 1536, in __call__
return self.func(*args)
File "/Users/<username>/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 283, in resize
self.show()
File "/Users/<username>/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 355, in draw
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
File "/Users/<username>/anaconda/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 30, in blit
id(data), colormode, id(bbox_array))
TclError
是什么导致了这个错误?我曾尝试将 backend: TkAgg
添加到我的 matplotlibrc
文件中,但无济于事.
What is causing this error? I have tried adding backend: TkAgg
to my matplotlibrc
file, to no avail.
请指教
推荐答案
您可以使用'TkAgg',但需要不与conda一起安装Tkinter.用于 pil/pillow 和 matplotlib 的 Anaconda 包似乎没有正确包含 TK.用 conda 安装 pip,然后运行 pip installpil matplotlib (Linux)
You can use 'TkAgg' but need to install Tkinter not with conda. The Anaconda packages for pil/pillow and matplotlib seem not to have TK properly included. Install pip with conda and then run pip install pillow matplotlib (Linux)
在windows上你可以使用gohlke的包 http://www.lfd.uci.edu/~gohlke/pythonlibs/用--force-reinstall枕头matplotlib安装
On windows you can use the packages from gohlke http://www.lfd.uci.edu/~gohlke/pythonlibs/ install with --force-reinstall pillow matplotlib
然后 Tkinter TkAgg 将工作.
then Tkinter TkAgg will work.
这篇关于TclError matplotlib 1.5.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!