python.exe已停止使用cx\U冻结
我正在开发一个将matplotlib绘图集成到PySideGUI中的工具。在我关闭GUI之前,所有的工作都很好;我收到错误消息“python.exe已停止工作”。我做了几次测试,我注意到了一些问题:python.exe已停止使用cx\U冻结,python,python-3.x,matplotlib,crash,cx-freeze,Python,Python 3.x,Matplotlib,Crash,Cx Freeze,我正在开发一个将matplotlib绘图集成到PySideGUI中的工具。在我关闭GUI之前,所有的工作都很好;我收到错误消息“python.exe已停止工作”。我做了几次测试,我注意到了一些问题: 如果我正在使用pythondebug运行该工具,那么当我关闭GUI时,我没有此消息 如果我是从shell运行工具,我也没有错误消息 这只出现在经典的python运行中;每当我在绘图后关闭GUI时 这是我的密码: import os import sys import pandas as pd i
- 如果我正在使用pythondebug运行该工具,那么当我关闭GUI时,我没有此消息李>
- 如果我是从shell运行工具,我也没有错误消息李>
import os
import sys
import pandas as pd
import PySide
import matplotlib
matplotlib.use('wxAgg')
matplotlib.rcParams['backend']='qt4agg'
matplotlib.rcParams['backend.qt4']='PySide'
from matplotlib.figure import figure
from matplotlib.backends.backend_qt4agg import (FigureCanvasQTAgg as FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
import matplotlib.pyplot as plt
class Main():
def __init__(self):
QtGui.QMainWindow.__init__(self)
#loading of the MainWindow and buttons initialization....
self.MainWindow.show()
sys.exit(app.exec_())
def plotGeneration(self):
fig=plt.figure(facecolor='white')
canvas=FigureCanvas(fig)
canvas.setParent(self.MainWindow)
ax=fig.add_subplot(111)
ax.set_xlabel('Date')
ax.set_ylabel('Time')
toolbar=NavigationToolbar(canvas, self.MainWindow, coordinates=True)
self.MainWindow.mplwindow.addWidget(toolbar, 0,0,1,1)
plt.clf() #tried from other post seen with this issue
try:
limit=self.MainWindow.limitTime.text()
ax.plot((self.dateList[0], max(self.dateList)), (int(limit), int(limit)), 'r')
except ValueError:
pass
ax.plot(self.dateList, self.timeList, 'o-')
canvas.draw()
self.MainWindow.gridLayoutPlot.addWidget(canvas, 0,0,1,1)
plt.close(fig) #Also tried from other posts
if __name__ == '__main__':
app=QtGui.QApplication(sys.argv)
MainWindow=Main()
MainWindow.show()
sys.exit(app.exec_())
其他类似问题对我来说都不管用,我使用的是Python 3.1和matplotlib 1.2.0
有人有主意吗?谢谢
更新
感谢下面的一条评论,我通过添加以下行解决了在使用基本python运行启动脚本时python31.exe崩溃的问题:
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
但是当我尝试使用cx\U freeze编译脚本时,仍然会收到相同的错误消息。我正在使用cx_freeze 4.2.3。在尝试释放内存时看起来像是一个问题……我认为它来自PySide(反复出现的问题)。可能是因为使用了
pyplot
。我以前在自己的PyQt代码中看到过这一点。在PySide/PyQt应用程序中嵌入matplotlib时,您可以使用matplotlib的面向对象接口,而应该使用matplotlib的面向对象接口。看。当它试图释放内存时,看起来像是个问题……我认为它来自PySide(反复出现的问题)。可能是因为使用了pyplot
。我以前在自己的PyQt代码中看到过这一点。在PySide/PyQt应用程序中嵌入matplotlib时,您可以使用matplotlib的面向对象接口,而应该使用matplotlib的面向对象接口。看见