Matplotlib 中的 LaTex 产生错误“对不起,但 C:#\bin\latex.exe 没有成功”

问题描述

我想在我的论文的 matplotlib.pyplot 图中使用 LaTex,但很难实现它。我已经从官方页面安装了 MikTex 并使用以下代码

plt.rc('text',usetex=True)

def f(t):
    return t ** 2

t1 = np.arange(0.0,2.0,0.1)

noise = np.random.randn(len(t1)) * 0.04


fig = plt.figure(figsize=(4,3),dpi=200)
ax = fig.add_subplot(1,1,1)
plt.scatter(t1,f(t1 + noise),facecolors='none',label='Values obtained by experiment',edgecolors='k')
plt.plot(t1,f(t1),ls='solid',label='Theoretical expectation',color='k')
plt.legend()

现在,如果我运行此命令,则会打开一个名为“Package Installation”的窗口:缺少所需的文件“tex\latex\type1cm\type1cm.sty”。该软件包将从以下位置安装:随机软件包存储库

现在,按下安装后,我得到:

RuntimeError: latex was not able to process the following string:
b'lp'

Here is the full report generated by latex:
This is pdfTeX,Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6730)
entering extended mode
(C:/Users/Leo/.matplotlib/tex.cache/d97ff769cca1b07656427b11e7187cec.tex
LaTeX2e <2018-04-01> patch level 5
(C:\Users\Leo\AppData\Local\Programs\MiKTeX\tex\latex\base\article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(C:\Users\Leo\AppData\Local\Programs\MiKTeX\tex\latex\base\size10.clo))

Sorry,but C:\Users\Leo\anaconda3\Library\miktex\texmfs\install\miktex\bin\latex.exe did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

  C:/Users/Leo/AppData/Local/MiKTeX/2.9/miktex/log/latex.log

You may want to visit the MiKTeX project page,if you need help.

latex.log 文件

2021-01-30 19:40:11,457+0100 INFO  latex - starting with command line: C:\Users\Leo\anaconda3\Library\miktex\texmfs\install\miktex\bin\latex.exe
2021-01-30 19:40:11,467+0100 INFO  latex - allowing kNown shell commands
2021-01-30 19:40:11,467+0100 INFO  latex - enabling input (output) from (to) processes
2021-01-30 19:43:47,029+0100 INFO  latex - starting with command line: C:\Users\Leo\anaconda3\Library\miktex\texmfs\install\miktex\bin\latex.exe -interaction=nonstopmode --halt-on-error C:\Users\Leo\.matplotlib\tex.cache\d97ff769cca1b07656427b11e7187cec.tex
2021-01-30 19:43:47,035+0100 INFO  latex - allowing kNown shell commands
2021-01-30 19:43:47,035+0100 INFO  latex - enabling input (output) from (to) processes
2021-01-30 19:45:27,837+0100 INFO  latex - installing package type1cm triggered by tex\latex\type1cm\type1cm.sty
2021-01-30 19:45:27,837+0100 FATAL latex - Administrative mode cannot be enabled (makes no sense) because this is not a shared MiKTeX setup.
2021-01-30 19:45:27,837+0100 FATAL latex - Info: 
2021-01-30 19:45:27,837+0100 FATAL latex - Source: Libraries\MiKTeX\Core\Session\config.cpp
2021-01-30 19:45:27,837+0100 FATAL latex - Line: 1270
2021-01-30 19:45:27,839+0100 INFO  latex - finishing with exit code 1

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...