Py2exe打包matplotlib库程序

普通打包出错: 

RuntimeError: Could not find the matplotlib data files
正确打包脚本 :

#Used successfully in Python2.5 with matplotlib 0.91.2 and PyQt4 (andQt 4.3.3)
from distutils.core import setup
import py2exe
 
#We need to import the glob module to search for all files.
import glob
 
#We need to exclude matplotlib backends not being used by thisexecutable. You may find
#that you need different excludes to create a working executable withyour chosen backend.
#We also need to include include various numerix libraries that theother functions call.
 
opts= {
'py2exe':{ "includes" : [ "matplotlib.backends",
"matplotlib.figure","pylab","numpy",
"matplotlib.backends.backend_tkagg"],
'excludes':['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg',
'_fltkagg','_gtk', '_gtkcairo', ],
'dll_excludes':['libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll']
}
}
 
#Save matplotlib-data to mpl-data ( It is located in thematplotlib\mpl-data
#folder and the compiled programs will look for it in \mpl-data
#note: using matplotlib.get_mpldata_info
data_files= [(r'mpl-data',glob.glob(r'C:\Python27\Lib\site-packages\matplotlib\mpl-data\*.*')),
#Because matplotlibrc does not have an extension, glob does not findit (at least I think that's why)
#So add it manually here:
(r'mpl-data',[r'C:\Python27\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']),
(r'mpl-data\images',glob.glob(r'C:\Python27\Lib\site-packages\matplotlib\mpl-data\images\*.*')),
(r'mpl-data\fonts',glob.glob(r'C:\Python27\Lib\site-packages\matplotlib\mpl-data\fonts\*.*'))]
 
#for console program use 'console = [{"script" :"scriptname.py"}]
setup(windows=[{"script": "full.py"}], options=opts, data_files=data_files)     
 



  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值