>记录生活, 工作的点点滴滴...

python matplotlab画图现: alloc: invalid block:

Python用matplotlab画图时, 出现

alloc: invalid block:同时windows 已停止工作的消息框

解决方式:

在安装目录下修改matplotlibrc文件

将backend修改为:

# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo
# MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG
# Template.
# You can also deploy your own backend outside of matplotlib by
# referring to the module name (which must be in the PYTHONPATH) as
# 'module://my_backend'.
#
# If you omit this parameter, it will always default to "Agg", which is a
# non-interactive backend.
#backend      : TkAgg
backend      : Agg


文件查找:

INSTALL/matplotlib/mpl-data/matplotlibrc, where INSTALL is something like /usr/lib/python3.5/site-packages on Linux, and maybe C:\Python35\Lib\site-packages on Windows. Every time you install matplotlib, this file will be overwritten, so if you want your customizations to be saved, please move this file to your user-specific matplotlib directory.  

backend文件解释


参考方案:https://teamtreehouse.com/community/alloc-invalid-block-error-when-generating-bar-chart-with-matplotlib


发表于:2018-01-25 10:15:55浏览(651) 评论(0) Python