Skip to content

RuntimeError: LaTeX was not able to process the following string: 'z=$\\\\mathregular{{}^{}_{\\\\}}$' in matplotlib #5076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
neuronphysics opened this issue Sep 15, 2015 · 17 comments

Comments

@neuronphysics
Copy link

I have been trying to generate Latex style plots for publication by

from __future__ import unicode_literals
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.colors as mplcol
import matplotlib.cm as cmx
import numpy as np
plt.switch_backend('PS') 
matplotlib.use('PS')
matplotlib.style.use('ggplot')
matplotlib.rcParams['axes.edgecolor']='black'
matplotlib.rcParams['axes.facecolor']= 'white'
matplotlib.rcParams['axes.grid']= False
matplotlib.rcParams['ytick.major.size']= 2
matplotlib.rcParams['ytick.minor.pad']= 0.05
matplotlib.rcParams['xtick.major.size']= 2
matplotlib.rcParams['xtick.minor.pad']= 0.25
matplotlib.rcParams['legend.frameon'] = False
matplotlib.rcParams['text.usetex']=True
matplotlib.rcParams['text.latex.unicode']=True
matplotlib.rcParams['ps.usedistiller']='xpdf'
matplotlib.rcParams['ps.distiller.res']= 9000
matplotlib.rcParams['savefig.dpi']= 500
value = "{" + str(round(r.value, 2)) + "}"
upper = "{+" + str(round(r.upper_error, 2)) + "}"
lower = "{\,-" + str(round(r.lower_error, 2)) + "}"
# format this in a format LaTeX can parse. Use mathregular so that the
# font is the same as all the other fonts on the plot.
ext = r"z=$\mathregular{{{value}^{upper}_{lower}}}$".format(
        value=value, upper=upper, lower=lower)
save_as_one_pdf(figures, params["plot_directory"] +
                    self.name+'.pdf' )

where I want to plot different figures in multiple pages with this function:

def save_as_one_pdf(figs, filename):
    """
    Save the figures into one long PDF file

    :param figs: list of figures to be saved as PDFs
    :param filename: place where the PDFs will be saved
    :return: none
    """

    # Save the pdfs as one file
    pp = PdfPages(filename)
    for fig in figs:
        pp.savefig(fig)
    pp.close()
    for fig in figs:
        plt.close(fig)

But when I ran my script I've got the following errors:

 File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2431, in savefig
    figure.savefig(self, format='pdf', **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py", line 1476, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2211, in print_figure
    **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2485, in print_pdf
    self.figure.draw(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py", line 1085, in draw
    func(*args)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2110, in draw
    a.draw(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py", line 595, in draw
    bbox, info, descent = self._get_layout(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py", line 320, in _get_layout
    ismath=ismath)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2044, in get_text_width_height_descent
    renderer=self)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py", line 670, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py", line 417, in make_dvi
    report))
RuntimeError: LaTeX was not able to process the following string:
'z=$\\\\mathregular{{0.27}^{+0.01}_{\\\\,-0.01}}$'
Here is the full report generated by LaTeX: 

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)
 restricted \write18 enabled.
entering extended mode
(./384610b05118db25834f6dd15bc90717.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 62 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 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)
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/helvet.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty))
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/courier.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-global.def))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)

Package geometry Warning: Over-specification in `h'-direction.
    `width' (5058.9pt) is ignored.


Package geometry Warning: Over-specification in `v'-direction.
    `height' (5058.9pt) is ignored.

)
No file 384610b05118db25834f6dd15bc90717.aux.
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1pnc.fd)
(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucsencs.def)
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1phv.fd)
! Undefined control sequence.
<recently read> \mathregular 

l.13 ...0000}{12.500000}{\sffamily z=$\mathregular
                                                  {{0.27}^{+0.01}_{\,-0.01}}$}
[1] (./384610b05118db25834f6dd15bc90717.aux) )
(see the transcript file for additional information)

even after I changed the text to
text = r"z=${value}^{upper}_{lower}$".format(
value=value, upper=upper, lower=lower)

I've got the following error:

 File "cluster.py", line 762, in save_as_one_pdf
    pp.savefig(fig)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2431, in savefig
    figure.savefig(self, format='pdf', **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py", line 1476, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2211, in     print_figure
**kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2485, in print_pdf
    self.figure.draw(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py", line 1085, in draw
func(*args)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2110, in draw
a.draw(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/axis.py", line 1116, in draw
renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/axis.py", line 1065, in _get_tick_bboxes
extent = tick.label1.get_window_extent(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py", line 798, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py", line 311, in _get_layout
ismath=False)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2044, in get_text_width_height_descent
renderer=self)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py", line 670, in get_text_width_height_descent
dvifile = self.make_dvi(tex, fontsize)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py", line 417, in make_dvi
report))
RuntimeError: LaTeX was not able to process the following string:
'lp'
Here is the full report generated by LaTeX: 

! Package unicode-math Error: Cannot be run with pdfLaTeX!
(unicode-math)                Use XeLaTeX or LuaLaTeX instead..

See the unicode-math package documentation for explanation.
Type  H <return>  for immediate help.

How can I make this all work or avoid this error?

@tacaswell tacaswell added this to the proposed next point release milestone Sep 15, 2015
@tacaswell
Copy link
Member

attn @zblz You have been poking at this recently, any insight?

@zblz
Copy link
Member

zblz commented Sep 15, 2015

I was poking at the non-latex stuff, but took a look to the issue. In the first case it's just that \mathregular is a matplotlib-only command, not latex, so it will fail when using usetex=1. I'm at a loss in the second, but I suspect it's not a problem with the mentioned string given that it complains that latex could not process the string lp, which has nothing to do with the one you are looking at. There is also the unicode-math warning, have you tried with matplotlib.rcParams['text.latex.unicode']=False?

@neuronphysics: The following minimal working example works fine, can you provide a similar one that shows the issue?

import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['text.usetex']=True
matplotlib.rcParams['text.latex.unicode']=True

string = r'z=${value}^{upper}_{lower}$'.format(
                value='{' + str(0.27) + '}',
                upper='{+' + str(0.01) + '}',
                lower='{-' + str(0.01) + '}')
print(string)

fig = plt.figure(figsize=(3,1))
fig.text(0.1,0.5,string,size=24,va='center')
fig.savefig('issue5076.pdf')
fig.savefig('issue5076.png')

@tacaswell
Copy link
Member

@zblz Thanks!

@neuronphysics
Copy link
Author

@zblz I suspect that it has something to do with the conflication of

 import pylab as plt
 plt.switch_backend('PS') 
 matplotlib.use('PS')

and using

 from matplotlib.backends.backend_pdf import PdfPages
 pp = PdfPages(filename) ?

Because I even ran the code with the way you have pointed out and I still get error messages.

@zblz
Copy link
Member

zblz commented Sep 15, 2015

Note that matplotlib.use('PS') has no effect if called after import matplotlib.pyplot or pylab. I'm not sure about pylab.switch_backend('PS').

The following example with all these things baked in still works for me, so I'm not sure these are the culprits:

import matplotlib
matplotlib.use('PS')
matplotlib.rcParams['text.usetex']=True
matplotlib.rcParams['text.latex.unicode']=True
import pylab as plt
plt.switch_backend('PS')

string = r'z=${value}^{upper}_{lower}$'.format(
                value='{' + str(0.27) + '}',
                upper='{+' + str(0.01) + '}',
                lower='{-' + str(0.01) + '}')
print(string)

fig = plt.figure(figsize=(3,1))
fig.text(0.1,0.5,string,size=24,va='center')
from matplotlib.backends.backend_pdf import PdfPages
pp = PdfPages('issue5076.pdf')
pp.savefig(fig)
pp.close()

@neuronphysics
Copy link
Author

Well, in the script I would get this error message

  File "/vol/rsz_irac_code/cluster.py", line 335, in fit_z
    self.name + ".pdf")
  File "/vol/rsz_irac_code/cluster.py", line 762, in save_as_one_pdf
    pp.savefig(fig)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2431, in savefig
    figure.savefig(self, format='pdf', **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py", line 1476, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2211, in print_figure
    **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2485, in print_pdf
    self.figure.draw(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py", line 1085, in draw
    func(*args)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2110, in draw
    a.draw(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/axis.py", line 1116, in draw
    renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/axis.py", line 1065, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py", line 798, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py", line 311, in _get_layout
    ismath=False)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2044, in get_text_width_height_descent
    renderer=self)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py", line 670, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py", line 417, in make_dvi
    report))
RuntimeError: LaTeX was not able to process the following string:
'lp'

and this warning at the beginning:

 /vol/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:1318: UserWarning:  This call to matplotlib.use() has no effect
 because the backend has already been chosen;
 matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
 or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)

@tacaswell
Copy link
Member

Can you reproduce this in a clean enviroment?

✔ /tmp 
14:59 $ conda create -p mpl_clean python=2.7 matplotlib
Fetching package metadata: ....
Solving package specifications: .
Package plan for installation in environment /tmp/mpl_clean:

The following NEW packages will be INSTALLED:

    cairo:           1.12.18-4        (soft-link)
    fontconfig:      2.11.1-4         (soft-link)
    freetype:        2.5.2-2          (soft-link)
    libgfortran:     1.0-0            (soft-link)
    libpng:          1.6.17-0         (soft-link)
    libxml2:         2.9.2-0          (soft-link)
    matplotlib:      1.4.3-np19py27_2 (soft-link)
    numpy:           1.9.2-py27_1     (soft-link)
    openblas:        0.2.14-1         (soft-link)
    openssl:         1.0.1k-1         (soft-link)
    pip:             7.1.2-py27_0     (soft-link)
    pixman:          0.26.2-0         (soft-link)
    py2cairo:        1.10.0-py27_2    (soft-link)
    pyparsing:       2.0.3-py27_0     (soft-link)
    pyqt:            4.11.3-py27_1    (soft-link)
    python:          2.7.10-0         (soft-link)
    python-dateutil: 2.4.2-py27_0     (soft-link)
    pytz:            2015.4-py27_0    (soft-link)
    qt:              4.8.6-3          (soft-link)
    readline:        6.2-2            (soft-link)
    setuptools:      18.1-py27_0      (soft-link)
    sip:             4.16.5-py27_0    (soft-link)
    six:             1.9.0-py27_0     (soft-link)
    sqlite:          3.8.4.1-1        (soft-link)
    system:          5.8-2            (soft-link)
    tk:              8.5.18-0         (soft-link)
    wheel:           0.24.0-py27_0    (soft-link)
    zlib:            1.2.8-0          (soft-link)

Proceed ([y]/n)? y

Linking packages ...
[      COMPLETE      ]|##################################################################################################################################################################################################################################################| 100%
#
# To activate this environment, use:
# $ source activate /tmp/mpl_clean
#
# To deactivate this environment, use:
# $ source deactivate
#
✔ /tmp 
14:59 $ source activate /tmp/mpl_clean
discarding /home/tcaswell/mc3/bin from PATH
prepending /tmp/mpl_clean/bin to PATH
(mpl_clean) ✔ /tmp 
15:00 $ python latex_error.py 
z=${0.27}^{+0.01}_{-0.01}$
(mpl_clean) ✔ /tmp 

latex_error.py is

import matplotlib
matplotlib.use('PS')
matplotlib.rcParams['text.usetex']=True
matplotlib.rcParams['text.latex.unicode']=True
import pylab as plt
plt.switch_backend('PS')

string = r'z=${value}^{upper}_{lower}$'.format(
                value='{' + str(0.27) + '}',
                upper='{+' + str(0.01) + '}',
                lower='{-' + str(0.01) + '}')
print(string)

fig = plt.figure(figsize=(3,1))
fig.text(0.1,0.5,string,size=24,va='center')
from matplotlib.backends.backend_pdf import PdfPages
pp = PdfPages('issue5076.pdf')
pp.savefig(fig)
pp.close()

as @zblz posted above

@neuronphysics
Copy link
Author

@tacaswell I can produce it!

@tacaswell
Copy link
Member

meaning the above works or the above generates an exception?

@neuronphysics
Copy link
Author

The point is that I don't have a root permission and the latex library is not installed on my machine and I use a share library. I am getting this error:

   /usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
   (/usr/share/texlive/texmf-dist/tex/latex/unicode-math/unicode-math.sty
   (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty)

   ! Package unicode-math Error: Cannot be run with pdfLaTeX!
   (unicode-math)                Use XeLaTeX or LuaLaTeX instead..

   See the unicode-math package documentation for explanation.
   Type  H <return>  for immediate help.
    ...                                              

   l.40   }\@ehd
   (/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty

   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !
   ! Fatal fontspec error: "cannot-use-pdftex"
   ! 
   ! The fontspec package requires either XeTeX or LuaTeX to function.
   ! 
   ! You must change your typesetting engine to, e.g., "xelatex" or "lualatex"
   ! instead of plain "latex" or "pdflatex".
   ! 
   ! See the fontspec documentation for further information.
   ! 
   ! For immediate help type H <return>.
   !...............................................  

   l.41  }

which I guess it means they are not installed or updated or not compatible. Do you think it might be a reason?

@tacaswell
Copy link
Member

That does not look like a complete error message and it is still not clear to me you ran to generate that error.

@tacaswell tacaswell modified the milestones: unassigned, proposed next point release (2.1) Sep 15, 2015
@jkseppan
Copy link
Member

The first error message shows the LaTeX packages ucs and inputenc being included:

(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-global.def))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def))

This originates from the usual matplotlib LaTeX unicode preamble. The problem in that case is that \mathregular is not LaTeX. The second case (after "even after I changed the text...") omits the full error message, but this line looks wrong to me:

(/usr/share/texlive/texmf-dist/tex/latex/unicode-math/unicode-math.sty

Nothing in matplotlib loads unicode-math.sty. Some pgf documentation refers to it (and mentions that setting it up can be hard). I think something else than the value of text has been modified between the two cases, possibly a text.latex.preamble setting, which should cause a big warning being output about that being unsupported.

@gguiomar
Copy link

I tried running the script that @tacaswell wrote on a clean enviroment and I get this error:

/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
z=${0.27}^{+0.01}_{-0.01}$
sh: latex: command not found
Traceback (most recent call last):
File "latex_error.py", line 18, in
pp.savefig(fig)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2473, in savefig
figure.savefig(self, format='pdf', *_kwargs)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/figure.py", line 1563, in savefig
self.canvas.print_figure(_args, *_kwargs)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2232, in print_figure
*_kwargs)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2536, in print_pdf
self.figure.draw(renderer)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/artist.py", line 62, in draw_wrapper
draw(artist, renderer, _args, *_kwargs)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/figure.py", line 1159, in draw
func(_args)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/artist.py", line 62, in draw_wrapper
draw(artist, renderer, *args, *_kwargs)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/text.py", line 749, in draw
bbox, info, descent = textobj._get_layout(renderer)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/text.py", line 352, in _get_layout
ismath=False)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2086, in get_text_width_height_descent
renderer=self)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/texmanager.py", line 675, in get_text_width_height_descent
dvifile = self.make_dvi(tex, fontsize)
File "/Users/gongui/mpl_clean/lib/python2.7/site-packages/matplotlib/texmanager.py", line 422, in make_dvi
report))
RuntimeError: LaTeX was not able to process the following string:
'lp'
Here is the full report generated by LaTeX:

@gguiomar
Copy link

I did a line by line check and the problem arises when we create the pdf, i.e. the line

pp = PdfPages('issue5076.pdf')

is run, the rest of the script runs perfectly fine.

@jkseppan
Copy link
Member

The relevant error message in that output is:

sh: latex: command not found

For some reason, the “latex” binary is not found by the shell. Perhaps it is installed in an unusual directory and some profile files need updating.

@gguiomar
Copy link

Reinstalled MacTeX and it works now, thanks!

@efiring
Copy link
Member

efiring commented Nov 16, 2016

Sounds like this can be closed now, so I will do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants