gpt4 book ai didi

python - TclError matplotlib 1.5.0

转载 作者:太空宇宙 更新时间:2023-11-04 10:16:27 26 4
gpt4 key购买 nike

使用下面的代码,生成一个 TclError。

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()

当我在终端中执行我的脚本时,我得到以下信息:

/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 文件中,但无济于事。

请指教

最佳答案

想通了:

而不是使用:

matplotlib.use('TkAgg')

使用:

matplotlib.use('Qt4Agg')

或任何其他后端

关于python - TclError matplotlib 1.5.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35145314/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com