【问题标题】:RuntimeError: latex was not able to process the following string: b'$1.0$'RuntimeError:latex 无法处理以下字符串:b'$1.0$'
【发布时间】:2018-12-21 22:55:44
【问题描述】:

MCVE:

import matplotlib.pyplot as plt
from matplotlib import rc

plt.rc('text', usetex = True)
plt.plot([1.0, 2.0], [3.0, 4.0])
plt.show()

抛出的错误如标题所述:

RuntimeError: latex is not able to process the following string:
b'$1.0$'


Here is the full report generated by latex:



<Figure size 432x288 with 1 Axes>

由于usetex 设置设置为True 而引发错误。如果设置为False,则不会发生错误。

我不知道为什么会发生这种情况,我认为(不确定)几周前相同的代码可以正常工作。

添加更多信息:

代码在一行中指出了错误:

exc=exc.output.decode('utf-8')))

【问题讨论】:

  • $ 是乳胶中的保留字符。试试在它前面加一个反斜杠?
  • @ar7 我的代码中没有任何“$”...
  • 忽略第一条评论。当然$ 是一个乳胶命令,$1.0$ 是有效的乳胶,所以它应该可以工作。你最近对你的安装做了什么吗? TeX 本身运行良好吗?
  • @ImportanceOfBeingErnest 我不知道。我只编写和重写代码。我刚刚检查了环境变量,它们看起来不错。我也使用 miktex 发行版(我不确定 TeX 本身运行良好是什么意思)。我刚刚编译了一份旧的 .tex 文档,运行起来没有问题。
  • 你的路径中有乳胶吗? IE。如果你 cd 到你正在运行这个 python 代码的目录并输入latex -help,它会工作吗?

标签: python matplotlib


【解决方案1】:

重新安装 miktex 解决了这个问题,但发生的原因尚不清楚。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-21
    • 1970-01-01
    • 2015-09-25
    • 2017-06-06
    • 2020-02-13
    相关资源
    最近更新 更多