ไม่สามารถใช้ลาเท็กซ์ในแปลงหลาม - RuntimeError: LaTeX ไม่สามารถประมวลผลสตริงต่อไปนี้: b'lp'

ฉันต้องการใช้ลาเท็กซ์สำหรับป้ายกำกับของตัวเลข แต่ได้รับข้อผิดพลาด
RuntimeError: LaTeX ไม่สามารถประมวลผลสตริงต่อไปนี้: b'lp'
นี่คือรายงานฉบับเต็มที่สร้างโดย LaTeX: < br/> เท่านี้ก็เรียบร้อย (ฉันไม่เห็นรายงานใดๆ เลย)

แก้ไข : นี่คือข้อผิดพลาดทั้งหมดที่ฉันได้รับ:

Traceback (most recent call last):
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 197, in __draw_idle_agg
    FigureCanvasAgg.draw(self)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 464, in draw
    self.figure.draw(self.renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1144, in draw
    renderer, self, dsu, self.suppressComposite)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 2426, in draw
    mimage._draw_list_compositing_images(renderer, self, dsu)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1138, in draw
    renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1078, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\text.py", line 967, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\text.py", line 353, in _get_layout
    ismath=False)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 230, in get_text_width_height_descent
    renderer=self)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 676, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 423, in make_dvi
    report))
RuntimeError: LaTeX was not able to process the following string:
b'lp'
Here is the full report generated by LaTeX: 

นี่คือรหัสของฉัน:

import numpy as np
from matplotlib import rc
import matplotlib.pyplot as plt
plt.close('all')

rc('text', usetex = True)

mu = np.linspace(0,10,100)
eta = mu**2

fig, ax = plt.subplots()
ax.plot(mu,eta,label= r'$\eta (\mu)$')
ax.set_title('Test')
ax.legend()
import matplotlib as mpl
mpl.rcParams['text.usetex']=True

แทน

from matplotlib import rc
rc('text', usetex = True)

แต่ก็ให้ผลเช่นเดียวกัน

  • สลับ
rc('text', usetex = True)

to

rc('text', usetex = False)

ป้องกันข้อผิดพลาดแต่ฉลากของผมไม่ได้เขียนด้วยลาเท็กซ์...

หลังจากท่องกูเกิ้ลมาเยอะ ฉันก็ขาดไอเดีย ใครสามารถช่วยฉันหน่อยได้ไหม?

การกำหนดค่าของฉันคือ:
- Python 3.6 (ฉันรันโค้ดใน spyder)
- MiKTeX 2.9
- Ghostscript 9.50
- Windows 10
- Edit : matplotlib 2.0. 2

แก้ไข: อัปเกรดเป็น matplotlib 3.1.1 ฉันได้รับข้อผิดพลาดต่อไปนี้:

Traceback (most recent call last):
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 304, in _run_checked_subprocess
    stderr=subprocess.STDOUT)
  File "C:\Users\Vincent\Anaconda3\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "C:\Users\Vincent\Anaconda3\lib\subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 209, in __init__
    super(SubprocessPopen, self).__init__(*args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Vincent\Anaconda3\lib\subprocess.py", line 992, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5.py", line 505, in _draw_idle
    self.draw()
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 388, in draw
    self.figure.draw(self.renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1709, in draw
    renderer, self, artists, self.suppressComposite)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 2607, in draw
    self._update_title_position(renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 2556, in _update_title_position
    if title.get_window_extent(renderer).ymin < top:
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\text.py", line 890, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\text.py", line 291, in _get_layout
    ismath="TeX" if self.get_usetex() else False)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 201, in get_text_width_height_descent
    s, fontsize, renderer=self)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 448, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 338, in make_dvi
    texfile], tex)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 308, in _run_checked_subprocess
    'found'.format(command[0])) from exc
RuntimeError: Failed to process string with tex because latex could not be found
Traceback (most recent call last):
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 304, in _run_checked_subprocess
    stderr=subprocess.STDOUT)
  File "C:\Users\Vincent\Anaconda3\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "C:\Users\Vincent\Anaconda3\lib\subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 209, in __init__
    super(SubprocessPopen, self).__init__(*args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Vincent\Anaconda3\lib\subprocess.py", line 992, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5.py", line 505, in _draw_idle
    self.draw()
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 388, in draw
    self.figure.draw(self.renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1709, in draw
    renderer, self, artists, self.suppressComposite)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 2607, in draw
    self._update_title_position(renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 2556, in _update_title_position
    if title.get_window_extent(renderer).ymin < top:
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\text.py", line 890, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\text.py", line 291, in _get_layout
    ismath="TeX" if self.get_usetex() else False)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 201, in get_text_width_height_descent
    s, fontsize, renderer=self)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 448, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 338, in make_dvi
    texfile], tex)
  File "C:\Users\Vincent\Anaconda3\lib\site-packages\matplotlib\texmanager.py", line 308, in _run_checked_subprocess
    'found'.format(command[0])) from exc
RuntimeError: Failed to process string with tex because latex could not be found

person Vincent mahé    schedule 05.11.2019    source แหล่งที่มา
comment
ควรมีข้อผิดพลาดมากกว่าหนึ่งบรรทัด? คุณช่วยแสดงให้ครบได้ไหม?   -  person ImportanceOfBeingErnest    schedule 05.11.2019
comment
ขอบคุณสำหรับการตอบกลับของคุณ. ฉันแก้ไขคำถามเพื่อแสดงข้อผิดพลาดทั้งหมดที่ฉันได้รับ นอกจากนี้ ฉันยังคงค้นหาปัญหาของฉันใน Google และเรียนรู้เกี่ยวกับแบ็กเอนด์ของ Matplotlib ฉันไม่คุ้นเคยกับสิ่งนี้ คุณรู้ไหมว่านี่อาจเป็นสาเหตุของปัญหาของฉันหรือไม่   -  person Vincent mahé    schedule 05.11.2019
comment
ไม่ สิ่งนี้ไม่เกี่ยวข้องกับแบ็กเอนด์ มันเกี่ยวกับการติดตั้งลาเท็กซ์ของคุณ แต่หากข้อผิดพลาดที่ลาเท็กซ์ส่งคืนเป็นเพียงสตริงว่าง ฉันเกรงว่าจะไม่รู้ว่าปัญหาคืออะไร   -  person ImportanceOfBeingErnest    schedule 05.11.2019
comment
matplotlib เวอร์ชันใด คุณกำลังอ้างอิงคำแนะนำจากสองเวอร์ชันหลักที่ผ่านมา   -  person Jody Klymak    schedule 05.11.2019
comment
เวอร์ชัน matplotlib ของฉันคือ 2.0.2   -  person Vincent mahé    schedule 06.11.2019
comment
ฉันอัปเกรดเป็น matplotlib 3.1.1 และฉันได้รับข้อผิดพลาดอื่นซึ่งดูเหมือนว่าจะระบุว่าฉันไม่มีลาเท็กซ์ ... ฉันเขียนการแก้ไขในตอนท้ายของคำถามเดิมเพื่อแสดงข้อผิดพลาดทั้งหมด   -  person Vincent mahé    schedule 06.11.2019


คำตอบ (1)


ประมาณครั้งที่ 5 ที่ฉันถอนการติดตั้งและติดตั้ง MikTeX ใหม่ และคราวนี้ปัญหาของฉันก็ได้รับการแก้ไขแล้ว เมื่อรันสคริปต์ python หน้าต่างสามบานเปิดขึ้นอย่างต่อเนื่องเพื่อขอการติดตั้งแพ็คเกจ ฉันแนบภาพหน้าจอคำตอบของหน้าต่างทั้งสามนี้มาด้วย หลังจากยอมรับที่จะติดตั้งแพ็คเกจเหล่านี้ สคริปต์ของฉันก็ทำงานได้ดี ก่อนหน้านี้ เมื่อถอนการติดตั้งและติดตั้ง MikTeX ใหม่ ฉันเห็นหน้าต่างขอให้ติดตั้งและยอมรับการติดตั้งแล้ว ฉันไม่รู้ว่าทำไมคราวนี้มันถึงใช้งานได้ทั้งๆ ที่ก่อนหน้านี้มันไม่ทำงาน... อย่างไรก็ตาม ปัญหาของฉันได้รับการแก้ไขแล้วด้วยการถอนการติดตั้งและติดตั้ง MiKTeX ใหม่ เรียกใช้สคริปต์และยอมรับแพ็คเกจ

หน้าต่างสำหรับการติดตั้งไฟล์จาก type1cm

หน้าต่างสำหรับการติดตั้งไฟล์จาก iftex

หน้าต่างสำหรับการติดตั้งไฟล์จาก zhmetrics

person Vincent mahé    schedule 18.11.2019