garrettj403 / SciencePlots

Matplotlib styles for scientific plotting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

kalkite opened this issue · comments

I tried with this code snippet to draw a sample graph.

with plt.style.context('science'):     
    plt.figure()     
    plt.plot(x, y)     
    plt.show()

But I amm getting the following error. is it because of matplotlib latest version problem?
RuntimeError: Failed to process string with tex because latex could not be found.

You need Latex installed on your computer. See the FAQ.

I did,I installed it with pip latek package. it didn't work. but I managed to make it work with some manjaro libraries. thank you.

@rajeshkalakoti

I did,I installed it with pip latek package. it didn't work. but I managed to make it work with some manjaro libraries. thank you.

Maybe you should install latex in your computer directly such that latex can be directly called as a command. I have fixed the same issue by the following command.

sudo apt-get install texlive-latex-extra texlive-fonts-recommended dvipng cm-super

while the cm-super is used for this error latex was not able to process the following string: b'lp'.

I tried with this code snippet to draw a sample graph.

with plt.style.context('science'):     
    plt.figure()     
    plt.plot(x, y)     
    plt.show()

But I amm getting the following error. is it because of matplotlib latest version problem? RuntimeError: Failed to process string with tex because latex could not be found.

I have the same error and latex is installed in this environment already

It worked a long time ago. But thanks for the reply.

@Dimple10 that issue is with the installation of Latex in your system. Check out this FAQ as said garrettj403.

If it does not work, tell us what your errors are copied from the clipboard, and try to run the command latex or pdflatex in the command prompt, as well as your OS and versions of the installed software.

i have a simila rissue but just with jupyter notebooks. If I run .py files from the command line the graphs render perfectly.
However when I run cell with plotting code and SciencePlots i get: RuntimeError: Failed to process string with tex because latex could not be found

It seems like the jupyter kernel does not find the latex installation because !which latex returns that there is no latex in PATH. However, which latex from the command line (with the same virtual environment activated) returns the location of the latex installation.

Okay, so the problem was that the Latex installation was not on the PATH variable that the jupyter notebook was looking at. It was different than the one that the terminal looks at. This was due to the startup files that apply differently. I got arround it by setting some jupyter.runathestart code int he settings.json.

Another question I have now for @garrettj403 specially is how to get rid of this annoying message: INFO:matplotlib.texmanager:No LaTeX-compatible font found for the serif fontfamily in rcParams. Using default.

The figures render fine and no error is thrown. The INFO message only dissapears if I set plt.rc('text', usetex=plt.rcParamsDefault['text.usetex']) but that is not what I want. I want SciencePlots to render the figure not tex from matplitlib. Any clue on why that info message is given?