当我在python shell中运行此脚本时,它可以正常工作,但是当我构建代码并运行“.exe”文件时,应用程序将无法启动。
from tkinter import *
import matplotlib,sys
matplotlib.use('TkAgg')
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
master=Tk()
master.title("graphe")
master.geometry("700x650+100+100")
f=Figure((5,5),dpi=100)
a=f.add_subplot(111)
a.plot([1,2,3,4,5,6],[2,5,6,8,9,10])
data=FigureCanvasTkAgg(f,master=master)
data.show()
data.get_tk_widget().pack()
setup.py
:
from cx_Freeze import setup,Executable
import sys
base=None
if(sys.platform=='win32'):
base="Win32GUI"
setup(name='application',
options={"build_exe":{"packages": ["tkinter","matplotlib","numpy","PIL","math"]}},
version="1.1",
executables=[Executable("graphe.py",base=base)]
)