I am trying to render plots using latex in Anaconda.
I am getting an error from Anaconda claiming it is unable to find latex. The error is below (hopefully rendered properly.
This is being caused when I input rcParams at the top of my script (code also included above the error)
plt.rcParams.update({
'text.usetex': True,
'font.family': 'serif',
})
Traceback (most recent call last):
File ~\anaconda3\Lib\site-packages\matplotlib\texmanager.py:255 in _run_checked_subprocess
report = subprocess.check_output(
File ~\anaconda3\Lib\subprocess.py:466 in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File ~\anaconda3\Lib\subprocess.py:548 in run
with Popen(*popenargs, **kwargs) as process:
File ~\anaconda3\Lib\site-packages\spyder_kernels\customize\spydercustomize.py:109 in __init__
super(SubprocessPopen, self).__init__(*args, **kwargs)
File ~\anaconda3\Lib\subprocess.py:1024 in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File ~\anaconda3\Lib\subprocess.py:1509 in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File c:\users\kenzi\documents\masters\bacstroke2.0\bacstroke2.0\studies\exp1\exp1_data\overplotting.py:76
plt.tight_layout(w_pad = 8)
File ~\anaconda3\Lib\site-packages\matplotlib\pyplot.py:2349 in tight_layout
return gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File ~\anaconda3\Lib\site-packages\matplotlib\figure.py:3509 in tight_layout
engine.execute(self)
File ~\anaconda3\Lib\site-packages\matplotlib\layout_engine.py:178 in execute
kwargs = get_tight_layout_figure(
File ~\anaconda3\Lib\site-packages\matplotlib\_tight_layout.py:266 in get_tight_layout_figure
kwargs = _auto_adjust_subplotpars(fig, renderer,
File ~\anaconda3\Lib\site-packages\matplotlib\_tight_layout.py:82 in _auto_adjust_subplotpars
bb += [martist._get_tightbbox_for_layout_only(ax, renderer)]
File ~\anaconda3\Lib\site-packages\matplotlib\artist.py:1415 in _get_tightbbox_for_layout_only
return obj.get_tightbbox(*args, **{**kwargs, "for_layout_only": True})
File ~\anaconda3\Lib\site-packages\matplotlib\axes\_base.py:4385 in get_tightbbox
ba = martist._get_tightbbox_for_layout_only(axis, renderer)
File ~\anaconda3\Lib\site-packages\matplotlib\artist.py:1415 in _get_tightbbox_for_layout_only
return obj.get_tightbbox(*args, **{**kwargs, "for_layout_only": True})
File ~\anaconda3\Lib\site-packages\matplotlib\axis.py:1325 in get_tightbbox
self._update_label_position(renderer)
File ~\anaconda3\Lib\site-packages\matplotlib\axis.py:2304 in _update_label_position
bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer)
File ~\anaconda3\Lib\site-packages\matplotlib\axis.py:2100 in _get_tick_boxes_siblings
tlb, tlb2 = axis._get_ticklabel_bboxes(ticks_to_draw, renderer)
File ~\anaconda3\Lib\site-packages\matplotlib\axis.py:1304 in _get_ticklabel_bboxes
return ([tick.label1.get_window_extent(renderer)
File ~\anaconda3\Lib\site-packages\matplotlib\axis.py:1304 in <listcomp>
return ([tick.label1.get_window_extent(renderer)
File ~\anaconda3\Lib\site-packages\matplotlib\text.py:959 in get_window_extent
bbox, info, descent = self._get_layout(self._renderer)
File ~\anaconda3\Lib\site-packages\matplotlib\text.py:378 in _get_layout
_, lp_h, lp_d = _get_text_metrics_with_cache(
File ~\anaconda3\Lib\site-packages\matplotlib\text.py:97 in _get_text_metrics_with_cache
return _get_text_metrics_with_cache_impl(
File ~\anaconda3\Lib\site-packages\matplotlib\text.py:105 in _get_text_metrics_with_cache_impl
return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~\anaconda3\Lib\site-packages\matplotlib\backends\backend_agg.py:226 in get_text_width_height_descent
return super().get_text_width_height_descent(s, prop, ismath)
File ~\anaconda3\Lib\site-packages\matplotlib\backend_bases.py:645 in get_text_width_height_descent
return self.get_texmanager().get_text_width_height_descent(
File ~\anaconda3\Lib\site-packages\matplotlib\texmanager.py:368 in get_text_width_height_descent
dvifile = cls.make_dvi(tex, fontsize)
File ~\anaconda3\Lib\site-packages\matplotlib\texmanager.py:300 in make_dvi
cls._run_checked_subprocess(
File ~\anaconda3\Lib\site-packages\matplotlib\texmanager.py:259 in _run_checked_subprocess
raise RuntimeError(
RuntimeError: Failed to process string with tex because latex could not be found
)
I am on a windows 11 system.
I saw there was a similar issue on here already (RuntimeError: Failed to process string with tex because latex could not be found) so I tried their suggestions.
I checked that latex was installed properly into the PATH environment. Typing latex into the command line gives : This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.10) (preloaded format=latex.fmt) restricted \write18 enabled. **
My version of latex has dvipng installed and registered in PATH as it appears in the command prompt when I type 'dvipng'
I didnt have ghostscript previously installed so I installed the latest version and added it to PATH.
Here is what my path looks like:(https://i.stack.imgur.com/MCFXn.png)
Despite all of this I am still getting the same error in my terminal when trying to render with latex. If anyone has any suggestions I would be very greatful.
Also this is my first time posting on here so please let me know if I could do anything better :)