FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

RuntimeError: latex was not able to process the following string: b'$\\\\mathdefault{-2}$' · Issue #17673 · matplotlib/matplotlib · GitHub

Repository navigation

RuntimeError: latex was not able to process the following string: b'$\\\\mathdefault{-2}$' #17673

Closed

Description

Bug report

Bug summary

Hi,

I am working on a linux system which I do not have root privileges to. As such, I have created a virtual environment so I can use modules as I need without installing them fully on the system.

I experienced an error when trying to use Latex as a text renderer for plots I am making for publication in my virtual environment.
I do not get an error and everything works fine when I run the same code snippet outside of my virtual environment and I need to work in my virtual environment as there are certain modules I need to compute other parts the code.

I am aware a similar issue was raised here the resolution appears to be reinstall/update whatever Tex distribution I have but I can not do that as I do not have root privileges on my system. So is there a work around I could use in my vitual environment?

Thanks in advance.

Code for reproduction

import matplotlib as mpl
mpl.use('Agg') # Use this backend for writing plots to file

import matplotlib.pyplot as plt
plt.style.use('seaborn-talk')
mpl.rcParams['figure.figsize'] = [10, 8]
mpl.rcParams['figure.autolayout'] = True
mpl.rcParams['text.usetex'] = True                     # <------- This seems to be issue
mpl.rcParams['font.family'] = 'serif'
mpl.rcParams['font.serif'] = 'Computer Modern Roman'
mpl.rcParams['lines.linewidth'] = 1.25
mpl.rcParams['lines.markersize'] = 6

# Simple Plot of Data
plt.plot(np.arange(10), np.sin(np.arange(10)))
plt.xlim(0, 2*np.pi)
plt.ylim(-3.2, 3.2)
plt.xlabel(r'$x$')
plt.ylabel(r'$u(x, t) / u_{rms}(x, t)$')
plt.show()

Actual outcome

Traceback (most recent call last):
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/texmanager.py", line 306, in _run_checked_subprocess
    stderr=subprocess.STDOUT)
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['latex', '-interaction=nonstopmode', '--halt-on-error', '/home/ecarroll/.cache/matplotlib/tex.cache/f0d1ad490f795d8f5a7626e4d07943a6.tex']' returned non-zero exit status 1.

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

Traceback (most recent call last):
  File "./Plotting/plot_lce_triaddynamics_snaps&video.py", line 333, in <module>
    plt.savefig(output_dir + "/SNAPS/Triad_SNAPS_{:05d}.png".format(2), format='png', dpi = 400)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/pyplot.py", line 723, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/figure.py", line 2203, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 2126, in print_figure
    **kwargs)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 514, in print_png
    FigureCanvasAgg.draw(self)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 393, in draw
    self.figure.draw(self.renderer)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/figure.py", line 1729, in draw
    self.tight_layout(**self._tight_parameters)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py", line 358, in wrapper
    return func(*args, **kwargs)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/figure.py", line 2496, in tight_layout
    pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/tight_layout.py", line 360, in get_tight_layout_figure
    pad=pad, h_pad=h_pad, w_pad=w_pad)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/tight_layout.py", line 109, in auto_adjust_subplotpars
    tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/tight_layout.py", line 110, in <listcomp>
    if ax.get_visible()])
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 4323, in get_tightbbox
    bb_xaxis = self.xaxis.get_tightbbox(renderer)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 1188, in get_tightbbox
    self._update_label_position(renderer)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 2021, in _update_label_position
    bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 2006, in _get_tick_boxes_siblings
    tlb, tlb2 = axx.xaxis._get_tick_bboxes(ticks_to_draw, renderer)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 1174, in _get_tick_bboxes
    for tick in ticks if tick.label1.get_visible()],
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 1174, in <listcomp>
    for tick in ticks if tick.label1.get_visible()],
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/text.py", line 905, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/text.py", line 300, in _get_layout
    clean_line, self._fontproperties, ismath=ismath)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 204, in get_text_width_height_descent
    s, fontsize, renderer=self)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/texmanager.py", line 458, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/texmanager.py", line 340, in make_dvi
    texfile], tex)
  File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/texmanager.py", line 319, in _run_checked_subprocess
    exc=exc.output.decode('utf-8'))) from exc
RuntimeError: latex was not able to process the following string:
b'$\\\\mathdefault{0}$'

Here is the full report generated by latex:
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode

(/home/ecarroll/.cache/matplotlib/tex.cache/f0d1ad490f795d8f5a7626e4d07943a6.te
x
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 3 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)

! LaTeX Error: File `type1ec.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
<read *>

l.6 \usepackage
               {type1ec}^^M
No pages of output.
Transcript written on f0d1ad490f795d8f5a7626e4d07943a6.log.

Expected outcome

The expected outcome should be a plot where all the text and labels are rendered in Tex

Matplotlib version

  • Operating system: Ubuntu 18.04.3 LTS
  • Matplotlib version: matplotlib==3.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): Default backend is TkAgg but I switch to use Agg in the code
  • Python version: 3.6.9
  • Jupyter version (if applicable):
  • Other libraries:
    Libraries in my virtual environment:
appdirs==1.4.4
certifi==2020.4.5.2
cffi==1.14.0
colorama==0.4.3
cryptography==2.9.2
cycler==0.10.0
data==0.4
decorator==4.4.2
distlib==0.3.0
filelock==3.0.12
funcsigs==1.0.2
future==0.18.2
h5py==2.10.0
icc-rt==2020.0.133
importlib-metadata==1.6.1
importlib-resources==2.0.1
intel-openmp==2020.0.133
Jinja2==2.11.2
joblib==0.15.1
kiwisolver==1.2.0
latex==0.7.0
latexbuild==0.2.2
llvmlite==0.33.0
Mako==1.1.3
Markdown==3.2.2
MarkupSafe==1.1.1
matplotlib==3.2.2
mpmath==1.1.0
numba==0.50.0
numpy==1.18.5
pandas==1.0.4
pbr==5.4.5
pdoc3==0.8.1
pipenv==2020.6.2
pycparser==2.20
PyOpenGL==3.1.5
pyOpenSSL==19.1.0
pyparsing==2.4.7
pyptex==1.0.1
python-dateutil==2.8.1
pytz==2020.1
PyYAML==5.3.1
scikit-learn==0.23.1
scipy==1.4.1
shutilwhich==1.1.0
six==1.15.0
stevedore==2.0.0
sympy==1.6
tempdir==0.7.1
threadpoolctl==2.1.0
virtualenv==20.0.23
virtualenv-clone==0.5.4
virtualenvwrapper==4.8.4
zipp==3.1.0

Libraries in my base Python:

appdirs==1.4.4
asn1crypto==0.24.0
attrs==17.4.0
backports.functools-lru-cache==1.4
backports.shutil-get-terminal-size==1.0.0
chardet==3.0.4
configparser==4.0.2
contextlib2==0.6.0.post1
cryptography==2.1.4
cycler==0.10.0
decorator==4.1.2
distlib==0.3.0
enum34==1.1.6
filelock==3.0.12
funcsigs==1.0.2
google-api-python-client==1.6.2
h5py==2.7.1
httplib2==0.10.3
idna==2.6
importlib-metadata==1.6.1
importlib-resources==2.0.1
ipaddress==1.0.17
ipython==5.5.0
ipython-genutils==0.2.0
keyring==10.6.0
keyrings.alt==3.0
lz4==0.10.1
matplotlib==2.1.1
mpmath==1.0.0
numpy==1.16.6
oauth2client==4.1.2
olefile==0.45.1
pathlib2==2.3.5
pbr==5.4.5
pexpect==4.2.1
pickleshare==0.7.4
Pillow==5.1.0
pluggy==0.6.0
progressbar2==3.34.2
prompt-toolkit==1.0.15
py==1.5.2
pyasn1==0.3.2
pyasn1-modules==0.0.11
pycairo==1.16.2
pycrypto==2.6.1
Pygments==2.2.0
pygobject==3.26.1
PyICU==1.9.8
PyOpenGL==3.1.0
pyOpenSSL==17.5.0
pyparsing==2.2.0
PySide==1.2.2
pytest==3.3.2
python-dateutil==2.6.1
python-lzo==1.8
python-utils==2.2.0
pytz==2018.3
pyxdg==0.25
rencode==1.0.5
rsa==3.4.2
scandir==1.10.0
SecretStorage==2.3.1
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.15.0
stevedore==1.32.0
subprocess32==3.2.7
traitlets==4.3.2
typing==3.7.4.1
uritemplate==3.0.0
virtualenv==20.0.23
virtualenv-clone==0.5.4
virtualenvwrapper==4.8.4
wcwidth==0.1.7
xpra==2.1.3
youtube-upload==0.8.0
zipp==1.2.0

Activity

  1. tacaswell commented on Jun 18, 2020

    Member

    The problem is a missing latex package that we began to require someplace between mpl 2.1.1 and mpl 3.2.2.

    See #16911 and links there in which chases back to #11381 .

    I think the solution is to either get cm-super (which is the source of type1ec.sty https://ctan.org/pkg/cm-super) installed on your system by the sysadmins or get a local install of latex.

  2. added this to the v3.3.0 milestone on Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL