带有matplotlib,numpy和pylab的py2exe [英] py2exe with matplotlib, numpy and pylab
本文介绍了带有matplotlib,numpy和pylab的py2exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试生成一个可执行文件.我正在使用的软件包是
I'm trying to generate an executable. the packages I am using are
import sys
import matplotlib.pyplot as plt
from pylab import *
from numpy import *
setup.py 如下
the setup.py is the following
from distutils.core import setup
import py2exe
import matplotlib
setup(console=['<python file>'],data_files=matplotlib.get_py2exe_datafiles(),)
但我收到一个与 pyplot.pyc 相关的错误
but I get an error related to pyplot.pyc
导入错误:没有名为backend_tkagg的模块
Import Error: no module named backend_tkagg
有什么办法解决吗?
推荐答案
您应该明确地包含 matplotlib 模块.如果这样做,则会从不可用的dll中得到一些错误,因此应排除它们.
适用于我的文件的设置:
You should include the matplotlib module explicitly.
If you do that you can get some errors from unavailable dlls, so then you should exclude them.
A setup that works for me with your file:
from distutils.core import setup
import py2exe
import matplotlib
setup(console=['afile.py'],
options={
'py2exe': {
'packages' : ['matplotlib', 'pytz'],
'dll_excludes': ['libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll',
'libgdk_pixbuf-2.0-0.dll',
'libgtk-win32-2.0-0.dll',
'libglib-2.0-0.dll',
'libcairo-2.dll',
'libpango-1.0-0.dll',
'libpangowin32-1.0-0.dll',
'libpangocairo-1.0-0.dll',
'libglade-2.0-0.dll',
'libgmodule-2.0-0.dll',
'libgthread-2.0-0.dll',
'QtGui4.dll', 'QtCore.dll',
'QtCore4.dll'
],
}
},
data_files=matplotlib.get_py2exe_datafiles(),)
这篇关于带有matplotlib,numpy和pylab的py2exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文