0

Python スクリプトから作業用のexeファイルを作成できません。matplotlibの使い方まで絞り込めたのですが、直し方がわかりません。

コマンドを使用してexeファイルを作成しますpyinstaller --onefile myScript.pyexeは、次のような「無視された」インポートで作成されます。

情報: Matplotlib バックエンド "GTK3Agg": 無視されたバックエンド Gtk3Agg には cairo が必要です

exeを実行すると、コマンド ウィンドウが表示され、エラーが発生して終了します。

エラー: ランタイム エラーにより、matplotlib データ ファイルが見つかりませんでした

Python ターミナルからコードを実行すると、すべて正常に動作します。matplotlib とグラフ関連の行を削除すると、exeが正しく作成されます。

一部 ( pyinstaller および matplotlib - error while executring .exe ) は、解決策は pyinstaller を更新することであると主張しています。私はしました、それは助けにはなりませんでした。

plt(コンソールを閉じたときの Python Matplotlib ランタイム エラー)を使用しないことを提案する人もいますが、関数を機能させることができませんでしsubplotた。

このリンク ( http://www.py2exe.org/index.cgi/MatPlotLib ) は関連していると思いますが、正確に何をする必要があるのか​​ わかりません。試してみると、他のエラーが発生しました。

これが私のコードです:

import  tkinter           as tk
import  tkinter.ttk       as ttk
import  matplotlib.pyplot as plt

class myApp(tk.Frame):
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        myFrame = ttk.LabelFrame(self.parent, text="FRAME", borderwidth=5)
        myFrame.grid(row=0, column=2, padx=5, pady=5, sticky='NS')
        myButton = ttk.Button(myFrame, width=12, text="SHOW GRAPH", command=self.showGraph)    .grid(row=0, column=1, sticky=tk.S)

    def showGraph(self):
        fig, axs = plt.subplots(2, 3)
        plt.show(block=False)


def main(root):
    app = myApp(root)
    root.wm_title("MyApp")
    root.mainloop()

if __name__ == "__main__":
    root = tk.Tk()
    main(root)
else:
    pass 

注: Windows 10、pip バージョン 20.2.2 で Python 3.8.3 を実行しています。

4

1 に答える 1