# !/usr/bin/env python
# -*- coding:utf8 -*-
"""
@file: setup
@time: 2016/5/17 11:31
"""
from distutils.core import setup
import py2exe
import glob
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']
}
}
data_files = ["analysischanneldatatool.ico",
(r'mpl-data', glob.glob(r'C:\Python27\Lib\site-packages\matplotlib\mpl-data\*.*')),
(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\*.*'))]
setup(
# options=options,
zipfile=None,
windows=[{"script": "test.py", "icon_resources": [(1, "test.ico")]}],
data_files=data_files,
version='Goku 1.0',
name='sqxu',
options=opts,
)
py2exe打包matplotlib后,打开程序提示错误Could not find the matplotlib data files,按上面修改setup.py后即可。
打包时需要添加matplotlib的一些文件路径信息,具体路径根据自己python安装的路径进行修改。