RuntimeError: Failed to process string with tex because latex could not be found

Sorry to add a trivial issue, but I am trying to generate some plots on the RSP and I have:

text.usetex : True
text.latex.preamble : \usepackage{amssymb} \usepackage{amsmath}

in my matplotlib style file. When I try to plot I get the following:

FileNotFoundError: [Errno 2] No such file or directory: 'latex'
...
RuntimeError: Failed to process string with tex because latex could not be found

I have tried pip install latex --user, restarting my kernal and logging out/in of the RSP completely with no joy.

I can live without it but would be nice to be able to use it to plot directly on the RSP.

Thanks!

Thanks for the question/description. Have you checked out the following notebook about working with user packages on the RSP?

Hi @steventgk, thanks for posting this.

I also tried pip install latex as you did, and can confirm that afterwards, which tex does not yield a response and that setting plt.rcParams['text.usetex'] = True in a notebook (I think similar to setting a matplotlib style file?) produces the same RuntimeError.

But, what’s the end goal? If you’re looking to use latex in axes labels, for example, the following works.

import matplotlib.pyplot as plt
import numpy as np

### Don't do this, it will raise an error
# plt.rcParams['text.usetex'] = True

xvals = np.arange(360)
yvals = np.cos(np.deg2rad(4.0 * np.pi * xvals)) + 2

fig = plt.figure(figsize=(6, 4))
plt.plot(xvals, yvals, 'o')
plt.xlabel('x')
plt.ylabel(r'Amplitude ($A = \cos(4\pi x) + 2$)')
plt.title(r'testing latex: $\left( \bar{bar} \frac{1}{2} \right) \ deg^2 \ sub_{\rm sub}$')
plt.show()

And in a markdown cell, equations in tex like

$E = mc^2$

will render like:
Screenshot 2025-06-30 at 7.50.26 PM

Is that what you were looking to do, or something else?

1 Like

Hi @MelissaGraham thanks for the reponse and your testing (and thank you @ameisner for your suggestion).

Like I mentioned, it’s not research-breaking, I just prefer the usetex styling and would like to stay consistent in my plots on and off the RSP. If there’s no easy fix, then I will certainly survive without it.

Thanks again!

Hi @steventgk , thanks for confirming that the existing math-formatted labels aren’t what you’re looking for, and that you’re after the overall usetex styling. That’s not an unreasonable request! And there may well be a fix out there. I’ve opened up an internal ticket for this (SP-2385) and we’ll report back. I get it - papers look much better (and referee complaints can be avoided) when figures all match stylistically.

In the meantime, if anyone else has gotten this to work in the RSP, do share here in thread.

1 Like

Hi again, after some internal discussion it turns out that LaTeX is not a part of the container yet because the distribution is enormous and has many evolving dependencies – and for the same reason, it is not recommended for individual users to try and install it (and the LaTeX installed with pip is not the full distribution, and is not expected to work like we expected, @steventgk).

Short term, the solution to this topic is that no, latex-style plots in the RSP are not possible at this time. But longer term, it is on the list for staff to consider as a future addition to the environment.

Thanks again for posting this question!

1 Like