Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带有matplotlib、numpy和pylab的py2exe_Python_Py2exe_Matplotlib - Fatal编程技术网

Python 带有matplotlib、numpy和pylab的py2exe

Python 带有matplotlib、numpy和pylab的py2exe,python,py2exe,matplotlib,Python,Py2exe,Matplotlib,我正在尝试生成一个可执行文件。我使用的软件包是 import sys import matplotlib.pyplot as plt from pylab import * from numpy import * setup.py如下所示 from distutils.core import setup import py2exe import matplotlib setup(console=['<python file>'],data_files=matplotlib.g

我正在尝试生成一个可执行文件。我使用的软件包是

import sys
import matplotlib.pyplot as plt
from pylab import *
from numpy import *  
setup.py如下所示

from distutils.core import setup
import py2exe
import matplotlib

setup(console=['<python file>'],data_files=matplotlib.get_py2exe_datafiles(),)   
来自distutils.core导入设置
导入py2exe
导入matplotlib
安装程序(控制台=[''],数据文件=matplotlib.get_py2exe_数据文件(),)
但是我得到了一个与pyplot.pyc相关的错误

导入错误:没有名为backend_tkagg的模块


有什么办法可以修复它吗?

您应该明确地包含matplotlib模块。 如果这样做,您可能会从不可用的DLL中获得一些错误,因此您应该排除它们。
适用于我的文件设置:

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(),)   
我需要添加(python2.7):


py2exe wiki有一个关于让matplotlib和py2exe工作的页面。请参阅,为了使其正常工作,我必须将
'excludes':['zmq']
添加到上述脚本中。否则,在运行安装脚本时,我会得到一个“未能找到libzmq.pyd”。
    import sys
    sys.path.append("C:\\pathToYourPython\\pythonxy2731\\console\\Microsoft.VC90.CRT")