py2exe `ImportError: No module named backend_tkagg`

耗尽温柔 提交于 2019-12-05 02:21:53

First, the easy question, is that backend installed? On my Fedora system I had to install it separately from the base matplotlib.

At a Python console can you:

>>> import matplotlib.backends.backend_tkagg

If that works, then force py2exe to include it. In your config:

opts = {
  'py2exe': { "includes" : ["matplotlib.backends.backend_tkagg"] }
}

If you are using py2exe it doesn't handle .egg formatted Python modules. If you used easy_install to install the trouble module then you might only have the .egg version. See the py2exe site for more info on how to fix it.

http://www.py2exe.org/index.cgi/ExeWithEggs

This works well

from distutils.core import setup import py2exe, sys, os import matplotlib

sys.setrecursionlimit(12000) sys.argv.append('py2exe')

setup( options = { "py2exe" : { "bundle_files":3, "compressed":True, "includes" : ["matplotlib.backends.backend_tkagg"] } }, windows = [{"script": "script.py"}],

zipfile = None,

data_files=matplotlib data_files = matplotlib.get_py2exe_datafiles(), )

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!