python py2exe打包matplotlib Could not find the matplotlib data files问题解决

来源:互联网 发布:js接口安全域名 备案 编辑:程序博客网 时间:2024/06/06 04:33
# !/usr/bin/env python# -*- coding:utf8 -*- """@file: setup@author: x00347195@time: 2016/5/17 11:31"""from distutils.core import setupimport py2exeimport globopts = {    '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安装的路径进行修改。


0 0
原创粉丝点击