Billingegroup / bg-mpl-stylesheets

Matplotlib style sheets
Other
4 stars 27 forks source link

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

Closed berrakozer closed 2 years ago

berrakozer commented 2 years ago

When using the bg_mpl_style on a Mac without latex installation the below error rises:

/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/_collections_abc.py:832: MatplotlibDeprecationWarning: Support for setting the 'text.latex.preamble' or 'pgf.preamble' rcParam to a list of strings is deprecated since 3.3 and will be removed two minor releases later; set it to a single string instead.
  self[key] = other[key]
Traceback (most recent call last):
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/texmanager.py", line 275, in _run_checked_subprocess
    report = subprocess.check_output(command,
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'latex'

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

Traceback (most recent call last):
  File "/Users/berrakozer/dev/pydatarecognition/pydatarecognition/main.py", line 129, in <module>
    main()
  File "/Users/berrakozer/dev/pydatarecognition/pydatarecognition/main.py", line 114, in main
    rank_plots = rank_plot(data_resampled[0][:,0], data_resampled[0][:, 1], cif_rank_pearson, cif_dict, OUTPUT_DIR)
  File "/Users/berrakozer/dev/pydatarecognition/pydatarecognition/plotters.py", line 80, in rank_plot
    plt.savefig(png_path / 'rank_plot.png', bbox_inches='tight')
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/pyplot.py", line 859, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/figure.py", line 2311, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2193, in print_figure
    self.figure.draw(renderer)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/figure.py", line 1863, in draw
    mimage._draw_list_compositing_images(
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
    a.draw(renderer)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
    return func(*inner_args, **inner_kwargs)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 2747, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
    a.draw(renderer)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/text.py", line 681, in draw
    bbox, info, descent = textobj._get_layout(renderer)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/text.py", line 287, in _get_layout
    _, lp_h, lp_d = renderer.get_text_width_height_descent(
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 227, in get_text_width_height_descent
    w, h, d = texmanager.get_text_width_height_descent(
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/texmanager.py", line 423, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/texmanager.py", line 309, in make_dvi
    self._run_checked_subprocess(
  File "/Users/berrakozer/anaconda3/envs/pydr/lib/python3.8/site-packages/matplotlib/texmanager.py", line 279, in _run_checked_subprocess
    raise RuntimeError(
RuntimeError: Failed to process string with tex because latex could not be found

Process finished with exit code 1
sbillinge commented 2 years ago

Thanks @berrakozer this is perfect!

maak-sdu commented 2 years ago

Requested by @sbillinge (feel free to add, edit, etc.): Per Thomas Caswell, mpl are using special fonts that are not in included every latex distribution (also, absent in absence of latex installation) but there is a way to use built-in fonts if the special fonts are not available, which may solve this issue.