ManimCommunity / manim

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

Unable to use MarkupText in any context. #2745

Closed Fillot closed 11 months ago

Fillot commented 2 years ago

Description of bug / unexpected behavior

Any call to MarkupText results in a ValueError:1. I've tried several configuration, confirming that it is MarkupText, and not any other kind of text. You don't have to self.add(text) to the scene, just calling MarkupText is enough. The code fails in ManimPango, in MarkupUtils.validate.

I'm using Ubuntu 20.04, python 3.8.6, and running manim in an anaconda environment, and I suspect the problems comes from this, as the installation in conda is a bit painful. I installed manim in an environment called graph using

conda activate graph
pip install ManimPango --force --no-cache
sudo apt install libcairo2-dev libpango1.0-dev ffmpeg
pip3 install manim

How to reproduce the issue

Code for reproducing the problem

This is one of the tutorial scene in the docs, I just added the line : mess = MarkupText('The horse does not eat cucumber salad.'). The scene runs as expected without it.

from manim import *

class MovingFrameBox(Scene):
    def construct(self):
        text=MathTex(
            "\\frac{d}{dx}f(x)g(x)=","f(x)\\frac{d}{dx}g(x)","+",
            "g(x)\\frac{d}{dx}f(x)"
        )
        mess = MarkupText('The horse does not eat cucumber salad.')
        self.play(Write(text))
        framebox1 = SurroundingRectangle(text[1], buff = .1)
        framebox2 = SurroundingRectangle(text[3], buff = .1)
        self.play(
            Create(framebox1),
        )
        self.wait()
        self.play(
            ReplacementTransform(framebox1,framebox2),
        )
        self.wait()

Traceback:

manim -pql scene.py MovingFrameBox
Manim Community v0.15.2

[05/29/22 12:23:15] INFO     Writing                      tex_file_writing.py:87
                             \frac{d}{dx}f(x)g(x)=                              
                             f(x)\frac{d}{dx}g(x) +                             
                             g(x)\frac{d}{dx}f(x) to medi                       
                             a/Tex/55ec78d41e955ccc.tex                         
This is METAFONT, Version 2.7182818 (MiKTeX 20.12)

(/home/tom/.miktex/texmfs/install/fonts/source/public/rsfs/rsfs7.mf
(/home/tom/.miktex/texmfs/install/fonts/source/public/cm/cmbase.mf)
(/home/tom/.miktex/texmfs/install/fonts/source/public/rsfs/script.mf
(/home/tom/.miktex/texmfs/install/fonts/source/public/rsfs/scriptu.mf [65]
[66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78] [79] [80]
[81] [82] [83] [84] [85] [86] [87] [88] [89] [90] [127]) ) )
Font metrics written on rsfs7.tfm.
Output written on rsfs7.600gf (27 characters, 6624 bytes).
Transcript written on rsfs7.log.
miktex-maketfm: major issue: So far, you have not checked for MiKTeX updates.
latex: major issue: So far, you have not checked for MiKTeX updates.
[05/29/22 12:23:31] INFO     Writing \frac{d}{dx}f(x)g(x)= to                               tex_file_writing.py:87
                             media/Tex/10c9f356dc3b8dc9.tex                                                       
latex: major issue: So far, you have not checked for MiKTeX updates.
                    INFO     Writing f(x)\frac{d}{dx}g(x) to media/Tex/308ee837d5aebed2.tex tex_file_writing.py:87
latex: major issue: So far, you have not checked for MiKTeX updates.
[05/29/22 12:23:32] INFO     Writing + to media/Tex/d44da29d0676df00.tex                    tex_file_writing.py:87
latex: major issue: So far, you have not checked for MiKTeX updates.
[05/29/22 12:23:33] INFO     Writing g(x)\frac{d}{dx}f(x) to media/Tex/4f182587344c1da9.tex tex_file_writing.py:87
latex: major issue: So far, you have not checked for MiKTeX updates.
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/tom/anaconda3/envs/graph/lib/python3.8/site-packages/manim/cli/render/commands.py:118 in   │
│ render                                                                                           │
│                                                                                                  │
│   115 │   │   for SceneClass in scene_classes_from_file(file):                                   │
│   116 │   │   │   try:                                                                           │
│   117 │   │   │   │   scene = SceneClass()                                                       │
│ ❱ 118 │   │   │   │   scene.render()                                                             │
│   119 │   │   │   except Exception:                                                              │
│   120 │   │   │   │   error_console.print_exception()                                            │
│   121 │   │   │   │   sys.exit(1)                                                                │
│                                                                                                  │
│ /home/tom/anaconda3/envs/graph/lib/python3.8/site-packages/manim/scene/scene.py:222 in render    │
│                                                                                                  │
│    219 │   │   """                                                                               │
│    220 │   │   self.setup()                                                                      │
│    221 │   │   try:                                                                              │
│ ❱  222 │   │   │   self.construct()                                                              │
│    223 │   │   except EndSceneEarlyException:                                                    │
│    224 │   │   │   pass                                                                          │
│    225 │   │   except RerunSceneException as e:                                                  │
│                                                                                                  │
│ /home/tom/Documents/Scientifique/Thesis/Code/Vizualization/videos/scene.py:9 in construct        │
│                                                                                                  │
│    6 │   │   │   "\\frac{d}{dx}f(x)g(x)=","f(x)\\frac{d}{dx}g(x)","+",                           │
│    7 │   │   │   "g(x)\\frac{d}{dx}f(x)"                                                         │
│    8 │   │   )                                                                                   │
│ ❱  9 │   │   mess = MarkupText('The horse does not eat cucumber salad.')                         │
│   10 │   │   self.play(Write(text))                                                              │
│   11 │   │   framebox1 = SurroundingRectangle(text[1], buff = .1)                                │
│   12 │   │   framebox2 = SurroundingRectangle(text[3], buff = .1)                                │
│                                                                                                  │
│ /home/tom/anaconda3/envs/graph/lib/python3.8/site-packages/manim/mobject/text/text_mobject.py:11 │
│ 36 in __init__                                                                                   │
│                                                                                                  │
│   1133 │   │   gradientmap = self._extract_gradient_tags()                                       │
│   1134 │   │   validate_error = MarkupUtils.validate(self.text)                                  │
│   1135 │   │   if validate_error:                                                                │
│ ❱ 1136 │   │   │   raise ValueError(validate_error)                                              │
│   1137 │   │                                                                                     │
│   1138 │   │   if self.line_spacing == -1:                                                       │
│   1139 │   │   │   self.line_spacing = (                                                         │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: 1

Here is the output from pip list

Package Version


appdirs 1.4.4 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 astroid 2.4.2 attrs 21.4.0 backcall 0.2.0 backports.functools-lru-cache 1.6.1 beautifulsoup4 4.11.1 bleach 5.0.0 brotlipy 0.7.0 certifi 2022.5.18.1 cffi 1.14.6 charset-normalizer 2.0.8 click 8.1.3 click-default-group 1.2.2 cloudpickle 2.0.0 cloup 0.13.1 colour 0.1.5 commonmark 0.9.1 cryptography 36.0.0 cycler 0.10.0 cytoolz 0.11.2 dask 2021.11.2 decorator 5.1.1 defusedxml 0.7.1 entrypoints 0.4 fastjsonschema 2.15.3 flit-core 3.7.1 fsspec 2021.11.1 glcontext 2.3.6 idna 3.1 imagecodecs-lite 2019.12.3 imageio 2.9.0 importlib-metadata 4.11.4 importlib-resources 5.7.1 ipykernel 5.3.4 ipython 7.19.0 ipython-genutils 0.2.0 ipywidgets 7.7.0 isort 5.6.4 isosurfaces 0.1.0 jedi 0.17.2 Jinja2 3.1.2 jsonschema 4.5.1 jupyter 1.0.0 jupyter-client 6.1.7 jupyter-console 6.4.2 jupyter-core 4.6.3 jupyterlab-pygments 0.2.2 jupyterlab-widgets 1.1.0 kiwisolver 1.3.1 lazy-object-proxy 1.4.3 locket 0.2.0 manim 0.15.2 ManimPango 0.4.1 mapbox-earcut 0.12.11 MarkupSafe 2.1.1 matplotlib 3.3.2 mccabe 0.6.1 mistune 0.8.4 moderngl 5.6.4 moderngl-window 2.4.1 multipledispatch 0.6.0 nbclient 0.5.13 nbconvert 6.4.5 nbformat 5.3.0 nest-asyncio 1.5.5 networkx 2.6.3 notebook 6.4.11 numpy 1.19.2 olefile 0.46 packaging 21.3 pandas 1.1.4 pandocfilters 1.5.0 parso 0.7.1 partd 1.2.0 pexpect 4.8.0 pickleshare 0.7.5 Pillow 9.1.1 pip 20.2.4 pooch 1.5.2 prometheus-client 0.14.1 prompt-toolkit 3.0.8 ptyprocess 0.6.0 pycairo 1.21.0 pycparser 2.20 pydub 0.25.1 pyglet 1.5.26 Pygments 2.12.0 PyGObject 3.40.1 pylint 2.6.0 pyOpenSSL 21.0.0 pyparsing 2.4.7 PyQt5 5.12.3 PyQt5-sip 4.19.18 PyQtChart 5.12 PyQtWebEngine 5.12.1 pyrr 0.10.3 pyrsistent 0.18.1 PySocks 1.7.1 python-dateutil 2.8.1 pytz 2020.4 PyWavelets 1.2.0 PyYAML 6.0 pyzmq 19.0.2 qtconsole 5.3.0 QtPy 2.1.0 requests 2.26.0 rich 12.4.2 scikit-image 0.18.1 scipy 1.8.1 screeninfo 0.8 seaborn 0.11.1 Send2Trash 1.8.0 setuptools 49.6.0.post20201009 six 1.15.0 skia-pathops 0.7.2 soupsieve 2.3.1 srt 3.5.2 terminado 0.15.0 testpath 0.6.0 tifffile 2019.7.26.2 toml 0.10.2 toolz 0.11.2 tornado 6.1 tqdm 4.64.0 traitlets 5.0.5 typing-extensions 4.2.0 urllib3 1.26.7 watchdog 2.1.8 wcwidth 0.2.5 webencodings 0.5.1 wheel 0.35.1 widgetsnbextension 3.6.0 wrapt 1.11.2 zipp 3.8.0 zstandard 0.14.0

Apologies if this should be posted in manimpango.

naveen521kk commented 2 years ago

What does python -c 'import manimpango; print(manimpango.pango_version())' print in you environment?

Fillot commented 2 years ago
python -c 'import manimpango; print(manimpango.pango_version())'
1.42.4
naveen521kk commented 2 years ago

Can you try installing ManimPango from the conda-forge channel and report if the issue still occurs, https://anaconda.org/conda-forge/manimpango?

I'm not sure why this issue occurs for me when raising ValueError, a text message is displayed telling where the error is.

behackl commented 11 months ago

Stale.