简体   繁体   English

libpng 错误:在设置 usetex=True 后使用 matplotlib 时读取错误

[英]libpng error: Read Error when using matplotlib after setting usetex=True

On two different machines running Windows 10, I am getting the error libpng error: Read Error leading to python crashing when trying to plot after setting the option usetex=True in matplotlib.在运行 Windows 10 的两台不同机器上,我收到错误libpng error: Read Error在 matplotlib 中设置选项usetex=True后尝试绘图时libpng error: Read Error导致 python 崩溃。 This has worked without problems before on this machine, I am not sure what changed since.这在这台机器上之前没有问题,我不确定从那以后发生了什么变化。

I have tried installing different libpng versions (1.6.32, 1.6.34, 1.6.36, 1.6.37) but all of them lead to the same outcome.我尝试安装不同的 libpng 版本(1.6.32、1.6.34、1.6.36、1.6.37),但它们都导致相同的结果。

A minimum example, directly after creating a fresh environment with conda create --name libpngtest python=3 matplotlib libpng :一个最小的例子,直接在使用conda create --name libpngtest python=3 matplotlib libpng创建一个新环境之后:

>>> import matplotlib.pyplot as plt
>>> from matplotlib import rc
>>> rc('text', usetex=True)
>>> plt.plot(1,2)
[<matplotlib.lines.Line2D object at 0x00000193015A8908>]
>>> plt.show()

At this point sometimes the python console just crashes out without any message, but I have also seen libpng error: Read Error printed before it crashes.在这一点上,有时 python 控制台会在没有任何消息的情况下崩溃,但我也看到libpng error: Read Error在崩溃之前打印的libpng error: Read Error Inside a jupyter notebook/lab, the kernel will restart and libpng error: Read Error appears in the terminal where jupyter is running between jupyter messages.在 jupyter notebook/lab 中,内核将重新启动,并且libpng error: Read Error出现在 jupyter 在 jupyter 消息之间运行的终端中。

At this point I am not sure if this is a python problem or a TeX problem (I have MikTeX 2.9 installed, which seems to be running fine), but would appreciate any hints you may have.在这一点上,我不确定这是 python 问题还是 TeX 问题(我安装了 MikTeX 2.9,它似乎运行良好),但希望您能得到任何提示。


Edit: The output after setting plt.set_loglevel("debug") is:编辑:设置plt.set_loglevel("debug")后的输出是:

DEBUG:matplotlib.texmanager:serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: serif, font: Computer Modern Roman, info: ('cmr', '')
DEBUG:matplotlib.texmanager:sans-serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:sans-serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: sans-serif, font: Computer Modern Sans Serif, info: ('cmss', '')
DEBUG:matplotlib.texmanager:cursive font is not compatible with usetex.
DEBUG:matplotlib.texmanager:cursive font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: cursive, font: Zapf Chancery, info: ('pzc', '\\usepackage{chancery}')
DEBUG:matplotlib.texmanager:monospace font is not compatible with usetex.
DEBUG:matplotlib.texmanager:monospace font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: monospace, font: Computer Modern Typewriter, info: ('cmtt', '')
DEBUG:matplotlib.texmanager:following keys changed: ['text.latex.preamble', 'text.latex.unicode', 'text.latex.preview', 'font.family', 'font.serif', 'font.sans-serif', 'font.cursive', 'font.monospace']
DEBUG:matplotlib.texmanager:text.latex.preamble : None       ->
DEBUG:matplotlib.texmanager:text.latex.unicode  : None       -> True
DEBUG:matplotlib.texmanager:text.latex.preview  : None       -> False
DEBUG:matplotlib.texmanager:font.family         : None       -> ['sans-serif']
DEBUG:matplotlib.texmanager:font.serif          : None       -> ['DejaVu Serif', 'Bitstream Vera Serif', 'Computer Modern Roman', 'New Century Schoolbook', 'Century Schoolbook L', 'Utopia', 'ITC Bookman', 'Bookman', 'Nimbus Roman No9 L', 'Times New Roman', 'Times', 'Palatino', 'Charter', 'serif']
DEBUG:matplotlib.texmanager:font.sans-serif     : None       -> ['DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', 'sans-serif']
DEBUG:matplotlib.texmanager:font.cursive        : None       -> ['Apple Chancery', 'Textile', 'Zapf Chancery', 'Sand', 'Script MT', 'Felipa', 'cursive']
DEBUG:matplotlib.texmanager:font.monospace      : None       -> ['DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Computer Modern Typewriter', 'Andale Mono', 'Nimbus Mono L', 'Courier New', 'Courier', 'Fixed', 'Terminal', 'monospace']
DEBUG:matplotlib.texmanager:RE-INIT
old fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.texmanager:serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: serif, font: Computer Modern Roman, info: ('cmr', '')
DEBUG:matplotlib.texmanager:sans-serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:sans-serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: sans-serif, font: Computer Modern Sans Serif, info: ('cmss', '')
DEBUG:matplotlib.texmanager:cursive font is not compatible with usetex.
DEBUG:matplotlib.texmanager:cursive font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: cursive, font: Zapf Chancery, info: ('pzc', '\\usepackage{chancery}')
DEBUG:matplotlib.texmanager:monospace font is not compatible with usetex.
DEBUG:matplotlib.texmanager:monospace font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: monospace, font: Computer Modern Typewriter, info: ('cmtt', '')
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\1acea6f6c115d0ec7a634ed0529287b9.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.dviread:['kpsewhich', 'cmss10.tfm']
DEBUG:matplotlib.dviread:stdout:
b'C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmss10.tfm\r\n'
DEBUG:matplotlib.dviread:stderr:
b''
DEBUG:matplotlib.dviread:opening tfm file C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmss10.tfm
DEBUG:matplotlib.dviread:lh=18, bc=0, ec=127, nw=52, nh=16, nd=11
DEBUG:matplotlib.dviread:['kpsewhich', 'cmss10.vf']
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\d598be7bdc6e0eeebdc83c75321a7705.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.dviread:['kpsewhich', 'cmr10.tfm']
DEBUG:matplotlib.dviread:stdout:
b'C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmr10.tfm\r\n'
DEBUG:matplotlib.dviread:stderr:
b''
DEBUG:matplotlib.dviread:opening tfm file C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmr10.tfm
DEBUG:matplotlib.dviread:lh=18, bc=0, ec=127, nw=36, nh=16, nd=10
DEBUG:matplotlib.dviread:['kpsewhich', 'cmr10.vf']
DEBUG:matplotlib.dviread:['kpsewhich', 'cmmi10.tfm']
DEBUG:matplotlib.dviread:stdout:
b'C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmmi10.tfm\r\n'
DEBUG:matplotlib.dviread:stderr:
b''
DEBUG:matplotlib.dviread:opening tfm file C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmmi10.tfm
DEBUG:matplotlib.dviread:lh=18, bc=0, ec=127, nw=98, nh=15, nd=9
DEBUG:matplotlib.dviread:['kpsewhich', 'cmmi10.vf']
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\1acea6f6c115d0ec7a634ed0529287b9.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\14cf46b44d83e91d3e4f12cc60007df3.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\1acea6f6c115d0ec7a634ed0529287b9.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\217de38979bbb592496a29d181b7bbc4.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\1acea6f6c115d0ec7a634ed0529287b9.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\3233f296f4d6994ca99a0d418d6458d8.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\1acea6f6c115d0ec7a634ed0529287b9.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.dviread:Dvi: C:\Users\...\.matplotlib\tex.cache\e2c00e1750b187927439ebc0ca3a1a38.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.texmanager:fontconfig: sans-serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e

I have found a way to skirt around the issue, though I would not call it a solution (with credit to anntzer on the matplotlib github repo, https://github.com/matplotlib/matplotlib/issues/16163 ).我找到了一种绕过这个问题的方法,尽管我不会称其为解决方案(归功于 matplotlib github 存储库中的 anntzer, https://github.com/matplotlib/matplotlib/issues/16163 )。 From matplotlib 3.2.0 libpng will no longer be used, so installing matplotlib 3.2.0-rc is a possible workaround.从 matplotlib 3.2.0 开始,将不再使用 libpng,因此安装 matplotlib 3.2.0-rc 是一种可能的解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 设置“matplotlib.rcParams[&#39;text.usetex&#39;] = True”以在标签中使用LaTeX并使用德语语言环境使用逗号时的Python图形问题 - Python figure problem when setting "matplotlib.rcParams['text.usetex'] = True" to use LaTeX in labels AND using the German locale to use the comma 使用matplotlib导出pdf时找不到字体使用usetex = True的Agg后端 - Can not find fonts when export pdf using matplotlib Agg backend with usetex=True Matplotlib在text.usetex == True时不使用乳胶字体 - Matplotlib not using latex font while text.usetex==True 使用MatPlotlib和LaTex文本渲染(usetex)创建.eps输出时出错 - Error creating .eps output with matplotlib with LaTex text rendering (usetex) 使用&#39;text.usetex&#39;= true时,pdf中嵌入的字体错误 - wrong fonts embedded in pdf when using 'text.usetex' = true matplotlib rc(&#39;text&#39;,usetex = True)产生错误 - matplotlib rc('text', usetex=True) producing errors matplotlib无法使用usetex = True输出EPS数字 - matplotlib fails to output EPS figure with usetex = True libpng 错误:从目录读取许多文件时读取错误 - libpng error: Read Error when reading many files from dir Matplotlib — libpng错误:应用程序和库中的libpng版本不兼容 - Matplotlib — libpng error: Incompatible libpng version in application and library 'libpng 错误:读取错误' 通过使用 open cv imread - 'libpng error: Read Error' by using open cv imread
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM