WassimTenachi / PhySO

Physical Symbolic Optimization
https://physo.readthedocs.io/
MIT License
1.81k stars 249 forks source link

! LaTeX Error: File `type1ec.sty' not found. #14

Closed jabowery closed 1 year ago

jabowery commented 1 year ago

As per README.md instructions I got the error upon running the suggested unit test:

$ uname -a
Linux ML 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ git clone https://github.com/WassimTenachi/PhySO
$ cd PhySO/
$ conda create -n PhySO python=3.8
$ conda activate PhySO
$ conda install --file requirements.txt
$ conda install --file requirements_display1.txt
$ pip install -r requirements_display2.txt
$ pip install -e .
$ python -m unittest discover -p "*UnitTest.py"

.Dummy epoch time = 138.905667 ms
.Dummy epoch time (w duplicate elimination) = 85.356149 ms (found 17/1000 candidates with R > 0 and 1/1000 with R = 1 +/- 0.000010)
.Dummy epoch time (w free const) = 3963.447029 ms (found 50/1000 candidates with R = 1 +/- 0.000010)
.Dummy epoch time (w free const and duplicate elimination) = 234.603148 ms (found 17/1000 candidates with R > 0 and 1/1000 with R = 1 +/- 0.000010)
.Dummy epoch time (w free const and duplicate elimination, keeping lowest complexity) = 210.498765 ms (found 17/1000 candidates with R > 0 and 1/1000 with R = 1 +/- 0.000010)
....
Required units time (in ideal non-mixed cases) : 0.006427 ms / step / (prog in batch) 
.
ComputeInfixNotation time = 0.010 ms
.
ExecuteProgram time = 2.828 ms
.
ExecuteProgram time = 2.264 ms
.LBFGS const opti: 1.499337 ms / step
................/home/jabowery/dev/PhySO/physo/physym/library.py:245: UserWarning: The units of token y were not provided (is_constraining_phy_units=False ; phy_units=[nan nan nan nan nan nan nan]), unable to compute units constraints.
  warnings.warn("The units of token %s were not provided (is_constraining_phy_units=%s ; phy_units=%s), "
/home/jabowery/dev/PhySO/physo/physym/library.py:245: UserWarning: The units of token x1 were not provided (is_constraining_phy_units=False ; phy_units=[nan nan nan nan nan nan nan]), unable to compute units constraints.
  warnings.warn("The units of token %s were not provided (is_constraining_phy_units=%s ; phy_units=%s), "
/home/jabowery/dev/PhySO/physo/physym/library.py:245: UserWarning: The units of token pi were not provided (is_constraining_phy_units=False ; phy_units=[nan nan nan nan nan nan nan]), unable to compute units constraints.
  warnings.warn("The units of token %s were not provided (is_constraining_phy_units=%s ; phy_units=%s), "
.......................get_infix_sympy time = 0.966 ms
get_infix_str time = 0.022 ms
F
get_tree_latex time = 0.859 s

get_tree_image time = 0.097 s

get_tree_image_via_tex time = 1.318 s

get_tree_latex time = 0.953 s

get_tree_image time = 0.097 s

get_tree_image_via_tex time = 1.305 s
.
Reward_SquashedNRMSE time = 0.283 ms
................
======================================================================
FAIL: test_infix_repr (physo.physym.tests.program_display_UnitTest.DisplayTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jabowery/anaconda3/envs/PhySO/lib/python3.8/site-packages/matplotlib/texmanager.py", line 233, in _run_checked_subprocess
    report = subprocess.check_output(
subprocess.CalledProcessError: Command '['latex', '-interaction=nonstopmode', '--halt-on-error', '../88161d9f41eeaed453da104b681404a4.tex']' returned non-zero exit status 1.

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

Traceback (most recent call last):
  File "/home/jabowery/dev/PhySO/physo/physym/tests/program_display_UnitTest.py", line 104, in test_infix_repr
    img = my_programs.get_infix_image(prog_idx=0,)
RuntimeError: latex was not able to process the following string:
b'lp'

Here is the full report generated by latex:
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(../88161d9f41eeaed453da104b681404a4.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-01-21>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)

! LaTeX Error: File `type1ec.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 

l.6 \usepackage
               [utf8]{inputenc}^^M
No pages of output.
Transcript written on 88161d9f41eeaed453da104b681404a4.log.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jabowery/dev/PhySO/physo/physym/tests/program_display_UnitTest.py", line 108, in test_infix_repr
    self.fail("Infix generation failed : get_infix_image")
AssertionError: Infix generation failed : get_infix_image

----------------------------------------------------------------------
Ran 70 tests in 23.099s

FAILED (failures=1)
WassimTenachi commented 1 year ago

Hi @jabowery,

It sounds like you are having problems with the functions producing latex versions of the expressions generated by physo.

I am unable to reproduce this error on my ubuntu system.

  1. Can you check that your version is:

    matplotlib >= 3.5.1
  2. Can you test that this snippet works correctly in the environment you are using to run physo ?

    
    import sympy
    import matplotlib.pyplot as plt

expr_str = "(sin(((ft)+phi))exp((alpha*-(t))))+1-1"

Getting a sympy expression

expr_sympy = sympy.parsing.sympy_parser.parse_expr(expr_str, evaluate=False)

If you want the simplified version

expr_sympy = sympy.simplify(expr_sympy, rational=True)

Getting a latex expression

expr_latex = sympy.latex (expr_sympy)

Getting a figure containing expression

fig, ax = plt.subplots(1, 1, figsize=(10, 2)) ax.axis('off') text_pos = (0.0, 0.5) ax.text(text_pos[0], text_pos[1], f'${expr_latex}$', size = 16)

plt.show()



3. It looks like you are not the only one having this problem with matplotlib + latex, maybe this is useful ?
https://stackoverflow.com/questions/11354149/python-unable-to-render-tex-in-matplotlib
jabowery commented 1 year ago

I corrected my situation by performing:

$ sudo apt install cm-super It's rather strange that this font isn't installable under at least conda if not pip if there are going to be such dependencies.

WassimTenachi commented 1 year ago

Yes it is strange. If a lot of users end up encountering this issue, I might change the plot font to avoid such issues.

ale-munozarancibia commented 1 year ago

In Fedora 35, I kept having the "not found" error for type1ec.sty and type1cm.sty in matplotlib although both were installed. I was able to solve it installing texlive-psutils with dnf.