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

问题描述 投票:0回答:1

[在运行Windows 10的两台不同机器上,在matplotlib中设置选项libpng error: Read Error后尝试绘图时,出现usetex=True错误,导致python崩溃。在此机器上,此操作之前没有问题,我不确定此后发生了什么更改。

我尝试安装不同的libpng版本(1.6.32、1.6.34、1.6.36、1.6.37),但所有这些都导致相同的结果。

一个最小的例子,直接在使用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()

[有时,python控制台只是崩溃而没有任何消息,但是我也看到libpng error: Read Error在崩溃前已打印出来。在jupyter笔记本/实验室中,内核将重新启动,并且在jupyter消息之间运行jupyter的终端中会显示libpng error: Read Error

此时,我不确定这是python问题还是TeX问题(我安装了MikTeX 2.9,似乎运行正常,但可能会收到任何提示。)>


编辑:设置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

在运行Windows 10的两台不同机器上,出现错误libpng错误:读取在matplotlib中设置选项usetex = True后尝试绘制时,导致Python崩溃的错误。这个...

python matplotlib tex libpng
1个回答
0
投票

我找到了解决该问题的方法,尽管我不会将其称为解决方案(感谢matplotlib github存储库https://github.com/matplotlib/matplotlib/issues/16163上的anntzer)。从matplotlib 3.2.0起,将不再使用libpng,因此可以安装matplotlib 3.2.0-rc。

© www.soinside.com 2019 - 2024. All rights reserved.