2016-07-27 6 views
0

私はIDEとしてLiClipseを使用してPython 3.4とPyQt4を使用してアプリケーションを開発していますが、プログラムを実行可能ファイルにコンパイルした後、私は問題点を指摘し、matplotlib.figure.Figure()を呼び出すことがクラッシュの原因であることを知っていますが、ここからどこに行くのかはわかりません。MatplotLibクラッシュを伴うEXE

import matplotlib 
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
from matplotlib.figure import Figure 
class GraphWidget(FigureCanvas): 
    def __init__(self,parent=None,width = 500, height = 600, dpi = 100): 

     self.width = width/dpi 
     self.height = height/dpi 
     self.dpi = dpi 

     #================crashes here=============# 
     self.figure = Figure((self.width,self.height), dpi=self.dpi) 
     #=========================================# 

     alert = QMessageBox() 
     alert.setText("Passed Figure()") 
     alert.exec_() 

     FigureCanvas.__init__(self,self.figure) 
     alert = QMessageBox() 
     alert.setText("Passed super init") 
     alert.exec_() 

     self.canvas = self 
     self.axis = self.figure.add_subplot(111) 
     self.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding) 
     self.parent = parent 

    def set_new_graph(self,data,labels): 
     self.layoutVert = QVBoxLayout(self) 
     size = QSize(self.width*self.dpi,self.height*self.dpi) 

     self.axis.hold(False) 

     mined = min(data.totalamount) - round(min(data.totalamount)*.1,0) 
     if mined > 0: mined = 0 
     maxed = max(data.totalamount) + round(max(data.totalamount)*.1,0) 
     if maxed == mined: maxed += 5 

     data.plot(x = data.totalamount 
        , ax = self.axis 
        , kind = 'bar' 
        , rot=0 
        , legend = False 
        , sharex = True 
        , sharey = True 
#     , xticks = labels 
        , ylim = (mined,maxed) 
        , table = False) 
#   self.axis.set_ylim(mined,maxed) 
     self.axis.set_xticklabels(labels, fontsize = 'small') 

     self.axis.set_title("Sales History over Past Year") 
     self.canvas.draw() 
     self.resize(size) 
     self.layoutVert.addWidget(self.canvas) 

マイpy2exeセットアップスクリプトは、グラフがページ上で初期化されている場合を除き、すべての機能のために使用可能な実行可能ファイルを生成します。

mpld = matplotlib.get_py2exe_datafiles() 
include = ['sip','pandas','reportlab' 
     , 'PyQt4' 
     , 'PyQt4.QtGui' 
     , 'PyQt4.QtCore' 
     , 'PyQt4.Qt' 
     ,'reportlab.rl_settings','scipy','win32com' 
     ,'win32com.client' 
     , 'matplotlib' 
     , 'matplotlib.backends' 
     , 'matplotlib.backends.backend_qt4agg' 
     , 'matplotlib.figure' 
     ] 

exclude = ['nbformat','win32com.gen_py',"six.moves.urllib.parse", 
    '_gtkagg', '_tkagg', '_agg2', 
    '_cairo', '_cocoaagg', 
    '_fltkagg', '_gtk', '_gtkcairo'] 

setup(name="ServiceMgmt", 
     # console based executables 
     console=[], 

     # windows subsystem executables (no console) 
     windows=['ServiceMgmt.py'], 

     # py2exe options 
     #zipfile=None, 
     options={"py2exe": py2exe_options}, 
     data_files=mpld 
     ) 

私は実行可能ファイルに自分のアプリケーションの他のすべての機能を実行することができていますが、問題なし。目に見えるエラーは表示されず、アプリケーションはコンパイルする前に正常に動作します。

ありがとうございました。

+0

[mcve]が便利です。たとえば、setup.py全体は、 'answer '(http://stackoverflow.com/a/11062854/5781248)のように' data_files = matplotlib.get_py2exe_datafiles() 'が存在するかどうかを知ります。 –

+0

@JJHakala、私はセットアップスクリプトを更新しました。私はdata_files = matplotlib.get_py2exe_datafiles()を使用します。 –

答えて

0

私のトラブルシューティングでは、問題の原因となっているnumpy.coreが見つかりました。私はnumpyを再インストールし、実行ファイルは正しく実行されました。

関連する問題