baidu_31402359
baidu_31402359
2015-12-09 05:47

关于Py2exe 打包pyqt4包含matplotlib的问题(python2.7)

10
  • python
  • pyqt
  • py2exe
  • matplolib

我想用py2exe打包一个pyqt4的项目,其中包括了matplotlib画图,生成exe的文件过程没有问题,但是双击exe后无法运行(也没有报错),代码如下:

from distutils.core import setup
import py2exe
import sys
import glob

#this allows to run it with a simple double click.
sys.argv.append('py2exe')

py2exe_options = {
"includes": ["sip","matplotlib.backends",

"matplotlib.figure","pylab","numpy",

"matplotlib.backends.backend_tkagg"],
'excludes':['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg',

'_fltkagg','_gtk', '_gtkcairo', ],

"dll_excludes": ["MSVCP90.dll",'libgdk-win32-2.0-0.dll',

'libgobject-2.0-0.dll'],
"compressed": 1,
"optimize": 2,
"ascii": 0,
"bundle_files": 1,
}
data_files= [(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(
name = 'test2',
version = '1.0',
windows = ['test2.py'],
zipfile = None,
options = {'py2exe': py2exe_options},
data_files=data_files
)

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答