我正在使用覆盆子PI 1上的python编程。当我尝试使用plt.savefig保存绘图时,我收到此错误,即使绘图的内容是单个值。我有一个Tkinter在一个主要的prosess上运行,我有一个单独的线程通过调用另一个.py文件中的函数进行一些计算,plt.savefig就是这些函数之一。 plt.savefig在直接调用第二个.py文件时工作正常,所以我猜这与我的线程有关?我的知识有点受限,我真的很感激一些帮助:(
编辑:
import threading
import time
import matplotlib.pyplot as plt
def saveplot():
plt.plot(3)
plt.savefig("plot.jpg")
time.sleep(10)
threads = []
t = threading.Thread(target=saveplot)
threads.append(t)
t.start()
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "Slett.py", line 6, in saveplot
plt.savefig("plot.jpg")
File "/usr/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 578, in savefig
draw() # need this if 'transparent=True' to reset colors
File "/usr/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 571, in draw
get_current_fig_manager().canvas.draw()
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 350, in draw
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/tkagg.py", line 21, in blit
_tkagg.tkinit(tk.interpaddr(), 1)
OverflowError: Python int too large to convert to C long
答案 0 :(得分:0)