ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
21.08k stars 1.53k forks source link

Error when trying to run Opening Manim Scene #879

Closed sydelcid closed 3 years ago

sydelcid commented 3 years ago

Description of bug / unexpected behavior

Hi, I am facing an error when trying to run Opening Manim Scene. Other examples seem to run fine. The issue seems to be on the "Tex" function. However, I'm also getting a lot of warnings even before this. I don't seem to face issues when not using "Tex", for example "MathTex" and "Text" work fine in various examples. However, when using "Text", it doesn't seem to fit the text on the canvas and it runs out of screen.

Expected behavior

Expected to produce the gif provided in the examples section.

How to reproduce the issue

Copied same code as provided in the Examples section "Opening Manim Scene".

Code for reproducing the problem ```py Paste your code here. ```

Additional media files

Images/GIFs

Logs

Terminal output ``` ❯ manim .\openmanim.py OpeningManim -v DEBUG c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-84 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-104 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-105 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-115 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-111 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-109 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-101 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-76 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g0-65 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-69 not recognized warnings.warn("%s not recognized" % ref) c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g1-88 not recognized warnings.warn("%s not recognized" % ref) Traceback (most recent call last): File "c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\__main__.py", line 84, in main scene.render() File "c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\scene\scene.py", line 90, in render self.construct() File "openmanim.py", line 4, in construct title = Tex("This is some \\LaTeX") File "c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\tex_mobject.py", line 362, in __init__ self.break_up_by_substrings(config) File "c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\tex_mobject.py", line 399, in break_up_by_substrings sub_tex_mob.move_to(self.submobjects[last_submob_index], RIGHT) IndexError: list index out of range ```

System specifications

System Details - OS: Windows 10 v2004 - RAM: 8GB - Python version (`python/py/python3 --version`): Python 3.8.5 - Installed modules (provide output from `pip list`): ``` cffi 1.14.3 chardet 3.0.4 click 7.1.2 cloudpickle 1.6.0 colorama 0.4.4 colour 0.1.5 commonmark 0.9.1 cryptography 3.2.1 cycler 0.10.0 Cython 0.29.21 cytoolz 0.11.0 dask 2.30.0 decorator 4.4.2 defusedxml 0.6.0 diff-match-patch 20200713 dill 0.3.3 dlx 1.0.4 docplex 2.17.199 docutils 0.16 entrypoints 0.3 fastdtw 0.3.4 fastjsonschema 2.14.5 flake8 3.8.4 future 0.18.2 h5py 3.1.0 idna 2.10 imageio 2.9.0 imagesize 1.2.0 importlib-metadata 2.0.0 inflection 0.5.1 intervaltree 3.1.0 ipykernel 5.3.4 ipython 7.19.0 ipython-genutils 0.2.0 ipywidgets 7.5.1 isort 5.6.4 jedi 0.17.2 Jinja2 2.11.2 joblib 0.17.0 jsonschema 3.2.0 jupyter-client 6.1.7 jupyter-core 4.6.3 jupyterlab-pygments 0.1.2 keyring 21.4.0 kiwisolver 1.3.0 lazy-object-proxy 1.4.3 lxml 4.6.1 manim 0.1.1 manimlib 0.1.11 MarkupSafe 1.1.1 matplotlib 3.3.2 mccabe 0.6.1 mistune 0.8.4 mkl-fft 1.2.0 mkl-random 1.1.1 mkl-service 2.3.0 more-itertools 8.6.0 mpmath 1.1.0 multitasking 0.0.9 mypy-extensions 0.4.3 nbclient 0.5.1 nbconvert 6.0.7 nbformat 5.0.8 nest-asyncio 1.4.2 networkx 2.5 notebook 6.1.4 ntlm-auth 1.5.0 numpy 1.19.2 numpydoc 1.1.0 olefile 0.46 opencv-python 4.4.0.46 packaging 20.4 pandas 1.1.3 pandas-datareader 0.9.0 pandocfilters 1.4.3 pangocairocffi 0.4.0 pangocffi 0.8.0 paramiko 2.7.2 parso 0.7.0 pathspec 0.7.0 pathtools 0.1.2 patsy 0.5.1 pexpect 4.8.0 pickleshare 0.7.5 Pillow 8.0.1 pip 20.2.4 pluggy 0.13.1 ply 3.11 progressbar 2.5 prometheus-client 0.8.0 prompt-toolkit 3.0.8 psutil 5.7.3 ptyprocess 0.6.0 pybind11 2.6.1 pycairo 1.20.0 pycodestyle 2.6.0 pycparser 2.20 pydocstyle 5.1.1 pydot 1.4.1 pydub 0.24.1 pyflakes 2.2.0 Pygments 2.7.2 pylatexenc 2.8 pylint 2.6.0 pyls-black 0.4.6 pyls-spyder 0.3.0 PyNaCl 1.4.0 pyOpenSSL 19.1.0 pyparsing 2.4.7 pyreadline 2.1 pyrsistent 0.17.3 PySocks 1.7.1 python-constraint 1.4.0 python-dateutil 2.8.1 python-jsonrpc-server 0.4.0 python-language-server 0.36.2 pytz 2020.1 PyWavelets 1.1.1 pywin32 227 pywin32-ctypes 0.2.0 pywinpty 0.5.7 PyYAML 5.3.1 pyzmq 19.0.2 QDarkStyle 2.8.1 qiskit 0.23.1 qiskit-aer 0.7.1 qiskit-aqua 0.8.1 qiskit-ibmq-provider 0.11.1 qiskit-ignis 0.5.1 qiskit-terra 0.16.1 QtAwesome 1.0.1 qtconsole 4.7.7 QtPy 1.9.0 Quandl 3.5.3 regex 2020.11.13 requests 2.24.0 requests-ntlm 1.1.0 retworkx 0.6.0 rich 6.2.0 rope 0.18.0 Rtree 0.9.4 scikit-image 0.17.2 scikit-learn 0.23.2 scipy 1.5.2 seaborn 0.11.0 Send2Trash 1.5.0 setuptools 50.3.1.post20201107 sip 4.19.13 six 1.15.0 snowballstemmer 2.0.0 sortedcontainers 2.3.0 Sphinx 3.4.0 sphinxcontrib-applehelp 1.0.2 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 1.0.3 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.4 spyder 4.2.0 spyder-kernels 1.10.1 statsmodels 0.12.0 sympy 1.6.2 terminado 0.9.1 testpath 0.4.4 threadpoolctl 2.1.0 three-merge 0.1.1 tifffile 2020.10.1 toml 0.10.1 toolz 0.11.1 tornado 6.0.4 tqdm 4.54.1 traitlets 5.0.5 typed-ast 1.4.1 typing-extensions 3.7.4.3 ujson 4.0.1 urllib3 1.25.11 watchdog 0.10.4 wcwidth 0.2.5 webencodings 0.5.1 websockets 8.1 wheel 0.35.1 widgetsnbextension 3.5.1 win-inet-pton 1.1.0 wincertstore 0.2 wrapt 1.11.2 yapf 0.30.0 yfinance 0.1.55 zipp 3.4.0 ```
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): MiKTex + Installed LaTeX packages: academicons actuarialangle actuarialsymbol amsfonts amsmath arabi atbegshi atveryend avantgar babel babel-english biber-windows-x64 biblatex bibtex blindtext bookman cbcoptic cm courier csfonts csplain dehyph doublestroke dvipdfmx dvips ec elhyphen enctex environ epstopdf-pkg etoolbox everyshi fontconfig fontspec fundus-calligra ghostscript graphics graphics-cfg graphics-def helvetic hyperref hyph-utf8 iftex jknappen knuth-lib l3backend l3kernel l3packages latex-firstaid latex-fonts listings lm ltxbase lualibs luaotfload luatex85 make4ht markdown mathalpha mathastext mathdesign mathfont metafont metapost microtype miktex-arctrl-bin-x64-2.9 miktex-asymptote-bin-x64-2.9 miktex-autosp-bin-x64-2.9 miktex-axohelp-bin-x64-2.9 miktex-bibarts-bin-x64-2.9 miktex-bibtex-bin-x64-2.9 miktex-bibtex8bit-bin-x64-2.9 miktex-bzip2-bin-x64-2.9 miktex-cairo-bin-x64-2.9 miktex-chktex-bin-x64-2.9 miktex-cjkutils-bin-x64-2.9 miktex-config-2.9 miktex-console-bin-x64-2.9 miktex-curl-bin-x64-2.9 miktex-cweb-bin-x64-2.9 miktex-devnag-bin-x64-2.9 miktex-dict-british miktex-dict-english miktex-dict-french miktex-dict-german miktex-dvicopy-bin-x64-2.9 miktex-dvipdfmx miktex-dvipdfmx-bin-x64-2.9 miktex-dvipng-bin-x64-2.9 miktex-dvips miktex-dvips-bin-x64-2.9 miktex-dvisvgm-bin-x64-2.9 miktex-epstopdf-bin-x64-2.9 miktex-expat-bin-x64-2.9 miktex-findtexmf-bin-x64-2.9 miktex-fmt-bin-x64-2.9 miktex-fontconfig miktex-fontconfig-bin-x64-2.9 miktex-fonts-bin-x64-2.9 miktex-freeglut-bin-x64-2.9 miktex-freetype2-bin-x64-2.9 miktex-fribidixetex-bin-x64-2.9 miktex-gd-bin-x64-2.9 miktex-ghostscript-bin-x64 miktex-graphite2-bin-x64-2.9 miktex-gregorio-bin-x64-2.9 miktex-gsf2pk-bin-x64-2.9 miktex-harfbuzz-bin-x64-2.9 miktex-hunspell-bin-x64-2.9 miktex-icu-bin-x64 miktex-jpeg-bin-x64-2.9 miktex-kpathsea-bin-x64-2.9 miktex-lacheck-bin-x64-2.9 miktex-latex miktex-lcdf-typetools-bin-x64-2.9 miktex-libressl-bin-x64-2.9 miktex-log4cxx-bin-x64-2.9 miktex-lua53-bin-x64-2.9 miktex-luatex miktex-luatex-bin-x64-2.9 miktex-lzma-bin-x64-2.9 miktex-m-tx-bin-x64-2.9 miktex-makeindex-bin-x64-2.9 miktex-md5-bin-x64-2.9 miktex-metafont miktex-metafont-bin-x64-2.9 miktex-metapost-bin-x64-2.9 miktex-mfware-bin-x64-2.9 miktex-misc miktex-mkfntmap-bin-x64-2.9 miktex-mktex-bin-x64-2.9 miktex-mo-bin-x64-2.9 miktex-mpfr-bin-x64-2.9 miktex-mpmcli-bin-x64-2.9 miktex-mspack-bin-x64-2.9 miktex-mthelp-bin-x64-2.9 miktex-mtprint-bin-x64-2.9 miktex-omegaware-bin-x64-2.9 miktex-patgen-bin-x64 miktex-pdftex miktex-pdftex-bin-x64-2.9 miktex-pixman-bin-x64-2.9 miktex-pmx-bin-x64-2.9 miktex-png-bin-x64-2.9 miktex-poppler-bin-x64-2.9 miktex-popt-bin-x64-2.9 miktex-posix-bin-x64-2.9 miktex-ps2pk-bin-x64-2.9 miktex-psutils-bin-x64-2.9 miktex-qt5-bin-x64 miktex-runtime-bin-x64-2.9 miktex-synctex-bin-x64-2.9 miktex-tdsutil-bin-x64 miktex-teckit-bin-x64-2.9 miktex-tex miktex-tex-bin-x64-2.9 miktex-tex2xindy-bin-x64-2.9 miktex-tex4ht miktex-tex4ht-bin-x64-2.9 miktex-texify-bin-x64-2.9 miktex-texware-bin-x64-2.9 miktex-texworks-bin-x64-2.9 miktex-ttf2pk2-bin-x64-2.9 miktex-ucrt-bin-x64 miktex-upmendex-bin-x64 miktex-uriparser-bin-x64-2.9 miktex-vc140-bin-x64 miktex-web-bin-x64-2.9 miktex-xetex miktex-xetex-bin-x64-2.9 miktex-xindy-bin-x64 miktex-yap-bin-x64-2.9 miktex-zip-bin-x64 miktex-zlib-bin-x64-2.9 miktex-zzip-bin-x64-2.9 modes mptopdf ms ncntrsbk oberdiek palatino pdftex pdftexcmds pgf pgfplots physics plain preview ragged2e relsize rsfs ruhyphen setspace standalone symbol tcolorbox tetex tex-ini-files tex4ht times tipa tools trimspaces ukrhyph unicode-data url wasy wasysym xcolor xetex xkeyval zapfchan zapfding
FFMPEG Output of `ffmpeg -version`: ``` ffmpeg version 4.3.1-2020-11-19-full_build-www.gyan.dev ```

Additional comments

tmelorc commented 3 years ago

Maybe the problem is conversion from dvi to svg.

naveen521kk commented 3 years ago

Looks like a problem with miktex. Where it didn't provide the necessary svg file. Maybe try reinstalling?

sydelcid commented 3 years ago

Thanks for looking into it. It seems to work perfectly fine with MathTex and Text. The "Tex" command gives error somehow, not sure why. Also, the warnings may be about the rendering, but the main error seems to be in substring split, if someone could comment on this:

File "openmanim.py", line 4, in construct title = Tex("This is some \LaTeX") File "c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\tex_mobject.py", line 362, in init self.break_up_by_substrings(config) File "c:\users\syd\anaconda3\envs\qclearnz\lib\site-packages\manim\mobject\svg\tex_mobject.py", line 399, in break_up_by_substrings sub_tex_mob.move_to(self.submobjects[last_submob_index], RIGHT) IndexError: list index out of range

behackl commented 3 years ago

title = Tex("This is some \LaTeX")

You either need to duplicate backslashes (\\LaTeX) or use raw strings (Tex(r"This is some \LaTeX")). The example in our documentation uses double backslashes (https://docs.manim.community/en/v0.1.1/examples.html#openingmanim).

In case this is just a display bug and you actually have double backslashes: can you please paste the full source code that you are trying to render, along with the full output of

manim .\openmanim.py OpeningManim -v DEBUG  --disable_caching

in a comment here?

naveen521kk commented 3 years ago

Also, please clean your media directory. --disable_caching doesn't check for it.

behackl commented 3 years ago

@sydelcid any update on this?

wurmfood commented 3 years ago

Not the original person, but I'm seeing the same behavior.

Code:

from manim import *

class Opening(Scene):
    def construct(self):
        title = Tex("Text")
        self.play(Write(title))
        self.wait()

Terminal output:

[12/30/20 13:54:52] INFO Writing "Text" to media\Tex\a5bd540987ea901a.tex tex_file_writing.py:81d:\david\repositories\manim.manimenv\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g0-84 not recognized warnings.warn("%s not recognized" % ref) d:\david\repositories\manim.manimenv\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g0-101 not recognized warnings.warn("%s not recognized" % ref) d:\david\repositories\manim.manimenv\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g0-120 not recognized warnings.warn("%s not recognized" % ref) d:\david\repositories\manim.manimenv\lib\site-packages\manim\mobject\svg\svg_mobject.py:239: UserWarning: g0-116 not recognized warnings.warn("%s not recognized" % ref)

Traceback (most recent call last): File "d:\david\repositories\manim.manimenv\lib\site-packages\manim__main__.py", line 84, in main scene.render() File "d:\david\repositories\manim.manimenv\lib\site-packages\manim\scene\scene.py", line 90, in render self.construct() File "Lessons\opening.py", line 6, in construct title = Tex("Text") File "d:\david\repositories\manim.manimenv\lib\site-packages\manim\mobject\svg\tex_mobject.py", line 362, in init self.break_up_by_substrings(config) File "d:\david\repositories\manim.manimenv\lib\site-packages\manim\mobject\svg\tex_mobject.py", line 399, in break_up_by_substrings sub_tex_mob.move_to(self.submobjects[last_submob_index], RIGHT) IndexError: list index out of range

Using Text instead of Tex works just fine. MathTex also works. However:

title = MathTex("\\text{Text}"}

will also fail with the same error as using Tex.

Finally, using latex commands from the terminal to render it as a PDF works just fine.

wurmfood commented 3 years ago

tldr: dvisvgm is broken with the default miktex install. If you get the version from the dvisvgm website (v. 2.11), it works.

Trying to find more information about this, I tried using dvisvgm directly.

PS D:\David\Repositories\manim\media\Tex> dvisvgm -p 1 .\9d34656f5a56ec89.dvi -n -v2 -o .\math.svg
PS D:\David\Repositories\manim\media\Tex> dvisvgm -p 1 .\a5bd540987ea901a.dvi -n -v2 -o .\tex.svg
WARNING: failed to create ecrm1000.gf
PS D:\David\Repositories\manim\media\Tex> dvisvgm -V
dvisvgm 2.8.2

Both DVIs work just fine (tested using yap from MikTex). It looks like it's the conversion that's the problem.

In the SVGs created, the ones that don't work are missing the paths under defs. That's why it can't find them. It looks like this might be a problem with dvisvgm. Assuming this to be true I downloaded the latest dvisvgm from https://dvisvgm.de/Downloads/. Replacing that version with the one from MikTex worked.

tmelorc commented 3 years ago

I also got problem with dvisvgm. So hat I did was run pdflatex instead of latex. I don't know what is advantage to use dvi instead of pdf.

pinjuf commented 3 years ago

Also had the exact same problem, replacing dvisvgm didn't help. I replaced MikTeX with TeX Live and everything worked perfectly fine.

behackl commented 3 years ago

We've had this report less often in recent times. The usual solution is to install the cm-super LaTeX package.