WassimTenachi / PhySO

Physical Symbolic Optimization

Home Page:https://physo.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

latex could not be found

dongzhe1989 opened this issue · comments

Hi Wassim,
I am trying to use the demo_mechanical_energy
but it run error.
the error message is below
Traceback (most recent call last):
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/texmanager.py", line 233, in _run_checked_subprocess
report = subprocess.check_output(
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/subprocess.py", line 858, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] 没有那个文件或目录: 'latex'

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

Traceback (most recent call last):
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/backends/backend_qt.py", line 455, in _draw_idle
self.draw()
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 436, in draw
self.figure.draw(self.renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/artist.py", line 73, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/figure.py", line 2810, in draw
mimage._draw_list_compositing_images(
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 3082, in draw
mimage._draw_list_compositing_images(
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/axis.py", line 1159, in draw
ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/axis.py", line 1085, in _get_tick_bboxes
return ([tick.label1.get_window_extent(renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/axis.py", line 1085, in
return ([tick.label1.get_window_extent(renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/text.py", line 910, in get_window_extent
bbox, info, descent = self._get_layout(self._renderer)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/text.py", line 309, in _get_layout
_, lp_h, lp_d = renderer.get_text_width_height_descent(
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 259, in get_text_width_height_descent
w, h, d = texmanager.get_text_width_height_descent(
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/texmanager.py", line 335, in get_text_width_height_descent
dvifile = self.make_dvi(tex, fontsize)
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/texmanager.py", line 271, in make_dvi
self._run_checked_subprocess(
File "/home/dz/miniconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/texmanager.py", line 237, in _run_checked_subprocess
raise RuntimeError(
RuntimeError: Failed to process string with tex because latex could not be found

Thank you.
dz

commented
  1. pip install latex
  2. Install latex app. brew install latex on macos. It's a little more complex on linux. You can search "install latex on linux".

solution:install texlive
sudo apt install texlive-full

Hi @dongzhe1989,

It sounds like latex is not installed properly on your system which PhySO uses to generate the Pareto front monitoring plot.

You can follow the advices of @hyfjjjj and @Noctise to install it (thank you guys so much for helping out) !

Wassim

on windwos10:https://cloud.tencent.com/developer/article/1944152。Some sections of code need to be modified.try this:
n_dim = X_array.shape[0]
with plt.style.context(['science', 'no-latex']):
fig, ax = plt.subplots(n_dim, 1, figsize=(10,5))
for i in range (n_dim):
curr_ax = ax if n_dim==1 else ax[i]
curr_ax.plot(X_array[i], y_array, 'k.',)
curr_ax.set_xlabel("X[%i]"%(i))
curr_ax.set_ylabel("y")
plt.show()
.......
def update_plot (self,):
epoch = self.run_logger.epoch
run_logger = self.run_logger
batch = self.batch

    # -------- Reward vs epoch --------
    with plt.style.context(['science', 'no-latex']):
        curr_ax = self.ax0
        curr_ax.clear()
        curr_ax.plot(run_logger.epochs_history, run_logger.mean_R_history        , 'b'            , linestyle='solid' , alpha = 0.6, label="Mean")

.....
def initialize (self):
with plt.style.context(['science', 'no-latex']):
self.fig = plt.figure(figsize=self.figsize)
gs = gridspec.GridSpec(3, 3)
......

thank you very much!@Noctise @WassimTenachi
use
sudo apt install texlive-full
is ok
Thank you.
dz