Pyinstaller打包运行exe报错 No module named matplotlib.backends.backend_tkagg

原文链接

I've seen this before, also on openSUSE (12.3). The fix is to edit the default matplotlibrc file.

Here's how you find where the default matplotlibrc file lives, and where it lives on my machine:

>>> import matplotlib
>>> matplotlib.matplotlib_fname()
'/usr/lib64/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc'

The backend setting is the first configuration option in this file. Change it from TkAgg to Agg, or to some other backend you have installed on your system. The comments in the matplotlibrc file list all backends supported by matplotlib.

The backend specified in this file is only the default; you can still change it at runtime by adding the following two lines, before any other matplotlib import:

import matplotlib
matplotlib.use("Agg")  # or whichever backend you wish to use
shareimprove this answer
 
1  
Good answer. Official matplotlib config example: matplotlib.org/users/customizing.html – Plamen Jun 29 '14 at 16:11 
 
This didn't work for me. However, I was able to fix the error by importing the backend module before importing matplotlib.pyplot. See my answer. I expect there is a better solution than mine that involves specifying the path to the backend modules. – user3731622 Aug 19 '15 at 23:10

也可参考  http://www.cnblogs.com/nima/p/4996058.html

阅读更多
个人分类: python
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

Pyinstaller打包运行exe报错 No module named matplotlib.backends.backend_tkagg

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭