Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.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 关于py2exe和matplotlib_Python_Matplotlib_Py2exe_Importerror - Fatal编程技术网

Python 关于py2exe和matplotlib

Python 关于py2exe和matplotlib,python,matplotlib,py2exe,importerror,Python,Matplotlib,Py2exe,Importerror,每天早上,我在使用py2exe打包一些.py文档时遇到一些问题。据我所知,问题与“matplotlib”库相对应,因为我可以在使用“matplotlib”之前成功地将过程打包。以下是启动“main.exe”时的错误提示 from distutils.core import setup import py2exe # Remove the build folder, a bit slower but ensures that build contains the latest import sh

每天早上,我在使用py2exe打包一些.py文档时遇到一些问题。据我所知,问题与“matplotlib”库相对应,因为我可以在使用“matplotlib”之前成功地将过程打包。以下是启动“main.exe”时的错误提示

from distutils.core import setup
import py2exe

# Remove the build folder, a bit slower but ensures that build contains the latest
import shutil
shutil.rmtree("build", ignore_errors=True)

# my setup.py is based on one generated with gui2exe, so data_files is done a bit differently
data_files = []
includes = ["sip","matplotlib.backends","matplotlib.backends.backend_qt4agg",
                                        "matplotlib.figure","pylab", "numpy",
                                        "matplotlib.backends.backend_tkagg"]
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger',
            'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
            'Tkconstants', 'Tkinter', 'pydoc', 'doctest', 'test', 'sqlite3'
            ]
packages = ['matplotlib','pytz']
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
                'tk84.dll','libgdk_pixbuf-2.0-0.dll']
icon_resources = []
bitmap_resources = []
other_resources = []

# add the mpl mpl-data folder and rc file
import matplotlib as mpl
data_files += mpl.get_py2exe_datafiles()

setup(
    console=["main.py","debug.py"],
                          # compressed and optimize reduce the size
    options = {"py2exe": {"compressed": 2, 
                          "optimize": 2,
                          "includes": includes,
                          "excludes": excludes,
                          "packages": packages,
                          "dll_excludes": dll_excludes,
                          # using 2 to reduce number of files in dist folder
                          # using 1 is not recommended as it often does not work
                          "bundle_files": 2,
                          "dist_dir": 'dist',
                          "custom_boot_script": '',
                         }
              },

    # using zipfile to reduce number of files in dist
    zipfile = r'lib\library.zip',

    data_files=data_files
)
错误提示: ImportError:无法导入名称统计信息


谢谢~

您是否尝试过将完整的
matplotlib
添加到您的include中,而不仅仅是后端和图形?我只是按照您所说的那样尝试了,但仍然犯了同样的错误…您在哪里使用/import
stats
(如错误中所示)?这是一个外部软件包还是您自己构建的软件包?我已经用另一种方式解决了这个问题,但仍然感谢您!你应该发布你的解决方案,作为其他遇到这个问题的人的答案