使用py2exe和matplotlib

来源:互联网 发布:有向网络最短路径 编辑:程序博客网 时间:2024/05/20 22:41

演示使用py2exe和matplotlib.

#Used successfully in PythonXY2.7.3 with py2exe ,wxPython 2.8.12 and matplotlib 1.2.0 from distutils.core import setupimport  matplotlibimport py2exe#----------------------------------------------------------------------------includes=["matplotlib","matplotlib.backends","matplotlib.figure","pylab","numpy","scipy","wx","matplotlib.backends.backend_tkagg","matplotlib.backends.backend_wxagg",]#----------------------------------------------------------------------------excludes=['_gtkagg', '_tkagg', '_agg2', '_cairo','_cocoaagg','_fltkagg','_gtk', '_gtkcairo']#----------------------------------------------------------------------------dll_excludes=['libgdk-win32-2.0-0.dll','libgobject-2.0-0.dll']#----------------------------------------------------------------------------options= {'py2exe':{ "includes" : includes,'excludes':excludes,'dll_excludes':dll_excludes}}#----------------------------------------------------------------------------data_files=matplotlib.get_py2exe_datafiles()#----------------------------------------------------------------------------#for windows program windows=[{"script": "D:\\Downloads\\wxMatPlotLib.py"},{"script": "D:\\Downloads\\test_wx.py"}]#----------------------------------------------------------------------------#for console programconsole = [{"script": "D:\\Downloads\\hello.py"}]#----------------------------------------------------------------------------setup(windows=windows, console=console,options=options, data_files=data_files)


 

主要是setup.py文件的编写很重要,要不然无法将python代码编译成exe可执行文件.上面是我的setup.py文件,保存于此,供以后参考.

 更详细的参考见http://www.py2exe.org/index.cgi/MatPlotLib

原创粉丝点击