ManimCommunity / manim

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

Cannot run example #3432

Closed alexk101 closed 10 months ago

alexk101 commented 10 months ago

Description of bug / unexpected behavior

I am trying to render the example code for ImageInterpolationEx for the ImageMobject here, but it seems that there is some kind of problem with the Text object and implicit parameters that are passed to it.

It is quite a weird bug, since the first text object seems to be parsed fine, but only the second one is a type error thrown. I suspect that there may be some internal side effects that aren't exposed in this code that cause this problem, but I am new to this project, so if it is the case that I have missed something, please let me know, but as is, the code example provided does not run for me.

Expected behavior

The code should render the image without runtime issues, however, when the code is run, it throws type errors.

How to reproduce the issue

Code for reproducing the problem ```py from manim import * import numpy as np class ImageInterpolationEx(Scene): def construct(self): img_data = np.uint8( [[63, 0, 0, 0], [0, 127, 0, 0], [0, 0, 191, 0], [0, 0, 0, 255]]) # type: ignore img = ImageMobject(img_data) img.height = 2 img1 = img.copy() img2 = img.copy() img3 = img.copy() img4 = img.copy() img5 = img.copy() img1.set_resampling_algorithm(RESAMPLING_ALGORITHMS["nearest"]) img2.set_resampling_algorithm(RESAMPLING_ALGORITHMS["lanczos"]) img3.set_resampling_algorithm(RESAMPLING_ALGORITHMS["linear"]) img4.set_resampling_algorithm(RESAMPLING_ALGORITHMS["cubic"]) img5.set_resampling_algorithm(RESAMPLING_ALGORITHMS["box"]) img1.add(Text("nearest").scale(0.5).next_to(img1,UP)) img2.add(Text("lanczos").scale(0.5).next_to(img2,UP)) img3.add(Text("linear").scale(0.5).next_to(img3,UP)) img4.add(Text("cubic").scale(0.5).next_to(img4,UP)) img5.add(Text("box").scale(0.5).next_to(img5,UP)) x= Group(img1,img2,img3,img4,img5) x.arrange() self.add(x) ```

Logs

Terminal output ``` Manim Community v0.17.3 ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /home/alexk101/.mambaforge/envs/manim/lib/python3.11/site-packages/manim/cli/render/commands.py: │ │ 115 in render │ │ │ │ 112 │ │ │ try: │ │ 113 │ │ │ │ with tempconfig({}): │ │ 114 │ │ │ │ │ scene = SceneClass() │ │ ❱ 115 │ │ │ │ │ scene.render() │ │ 116 │ │ │ except Exception: │ │ 117 │ │ │ │ error_console.print_exception() │ │ 118 │ │ │ │ sys.exit(1) │ │ │ │ /home/alexk101/.mambaforge/envs/manim/lib/python3.11/site-packages/manim/scene/scene.py:223 in │ │ render │ │ │ │ 220 │ │ """ │ │ 221 │ │ self.setup() │ │ 222 │ │ try: │ │ ❱ 223 │ │ │ self.construct() │ │ 224 │ │ except EndSceneEarlyException: │ │ 225 │ │ │ pass │ │ 226 │ │ except RerunSceneException as e: │ │ │ │ /home/alexk101/Documents/Research/Bertenthal/local-global-attention/src/viz.py:27 in construct │ │ │ │ 24 │ │ img4.set_resampling_algorithm(RESAMPLING_ALGORITHMS["cubic"]) │ │ 25 │ │ img5.set_resampling_algorithm(RESAMPLING_ALGORITHMS["box"]) │ │ 26 │ │ img1.add(Text("nearest").scale(0.5).next_to(img1,UP)) │ │ ❱ 27 │ │ img2.add(Text("lanczos").scale(0.5).next_to(img2,UP)) │ │ 28 │ │ img3.add(Text("linear").scale(0.5).next_to(img3,UP)) │ │ 29 │ │ img4.add(Text("cubic").scale(0.5).next_to(img4,UP)) │ │ 30 │ │ img5.add(Text("box").scale(0.5).next_to(img5,UP)) │ │ │ │ /home/alexk101/.mambaforge/envs/manim/lib/python3.11/site-packages/manim/mobject/text/text_mobje │ │ ct.py:486 in __init__ │ │ │ │ 483 │ │ │ self.line_spacing = self._font_size + self._font_size * self.line_spacing │ │ 484 │ │ │ │ 485 │ │ color = Color(color) if color else VMobject().color │ │ ❱ 486 │ │ file_name = self._text2svg(color) │ │ 487 │ │ PangoUtils.remove_last_M(file_name) │ │ 488 │ │ super().__init__( │ │ 489 │ │ │ file_name, │ │ │ │ /home/alexk101/.mambaforge/envs/manim/lib/python3.11/site-packages/manim/mobject/text/text_mobje │ │ ct.py:814 in _text2svg │ │ │ │ 811 │ │ │ width = config["pixel_width"] │ │ 812 │ │ │ height = config["pixel_height"] │ │ 813 │ │ │ │ │ ❱ 814 │ │ │ svg_file = manimpango.text2svg( │ │ 815 │ │ │ │ settings, │ │ 816 │ │ │ │ size, │ │ 817 │ │ │ │ line_spacing, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ TypeError: Argument 'size' has incorrect type (expected int, got float) ```

System specifications

System Details OS: ``` Chassis: laptop 💻 Machine ID: 1ef592510446496fb3b37c21e75aa1e2 Boot ID: 542ad976a94f49ecba5df511f4832f28 Operating System: EndeavourOS Kernel: Linux 6.5.9-arch2-1 Architecture: x86-64 Hardware Vendor: Lenovo Hardware Model: Legion 5 Pro 16ARH7H Firmware Version: JUCN59WW Firmware Date: Wed 2023-03-15 Firmware Age: 7month 2w 4d ``` - RAM: 32GB - Python version: Python 3.11.6 - Installed modules (provide output from `conda list`): ``` # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 2_gnu conda-forge aom 3.6.1 h59595ed_0 conda-forge attrs 23.1.0 pyh71513ae_1 conda-forge brotli-python 1.1.0 py311hb755f60_1 conda-forge bzip2 1.0.8 h7f98852_4 conda-forge ca-certificates 2023.7.22 hbcca054_0 conda-forge cachecontrol 0.13.1 pyhd8ed1ab_0 conda-forge cachecontrol-with-filecache 0.13.1 pyhd8ed1ab_0 conda-forge cairo 1.18.0 h3faef2a_0 conda-forge certifi 2023.7.22 pyhd8ed1ab_0 conda-forge cffi 1.16.0 py311hb3a22ac_0 conda-forge charset-normalizer 3.3.2 pyhd8ed1ab_0 conda-forge cleo 2.1.0 pyhd8ed1ab_0 conda-forge click 8.1.7 unix_pyh707e725_0 conda-forge click-default-group 1.2.4 pyhd8ed1ab_0 conda-forge cloup 0.13.1 pyhd8ed1ab_0 conda-forge colorama 0.4.6 pyhd8ed1ab_0 conda-forge colour 0.1.5 py_0 conda-forge crashtest 0.4.1 pyhd8ed1ab_0 conda-forge cryptography 41.0.5 py311h63ff55d_0 conda-forge dataclasses 0.8 pyhc8e2a94_3 conda-forge dav1d 1.2.1 hd590300_0 conda-forge dbus 1.13.6 h5008d03_3 conda-forge decorator 5.1.1 pyhd8ed1ab_0 conda-forge distlib 0.3.7 pyhd8ed1ab_0 conda-forge dulwich 0.21.6 py311h459d7ec_2 conda-forge expat 2.5.0 hcb278e6_1 conda-forge ffmpeg 5.1.2 gpl_hf01f75b_112 conda-forge filelock 3.13.1 pyhd8ed1ab_0 conda-forge font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge font-ttf-inconsolata 3.000 h77eed37_0 conda-forge font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge font-ttf-ubuntu 0.83 hab24e00_0 conda-forge fontconfig 2.14.2 h14ed4e7_0 conda-forge fonts-conda-ecosystem 1 0 conda-forge fonts-conda-forge 1 0 conda-forge freetype 2.12.1 h267a509_2 conda-forge fribidi 1.0.10 h36c2ea0_0 conda-forge future 0.18.3 pyhd8ed1ab_0 conda-forge gettext 0.21.1 h27087fc_0 conda-forge glcontext 2.5.0 py311hb755f60_0 conda-forge glib 2.78.0 hfc55251_0 conda-forge glib-tools 2.78.0 hfc55251_0 conda-forge gmp 6.2.1 h58526e2_0 conda-forge gnutls 3.7.8 hf3e180e_0 conda-forge graphite2 1.3.13 h58526e2_1001 conda-forge harfbuzz 8.2.1 h3d44ed6_0 conda-forge icu 73.2 h59595ed_0 conda-forge idna 3.4 pyhd8ed1ab_0 conda-forge importlib-metadata 6.8.0 pyha770c72_0 conda-forge importlib_metadata 6.8.0 hd8ed1ab_0 conda-forge importlib_resources 6.1.0 pyhd8ed1ab_0 conda-forge isosurfaces 0.1.0 pyhd8ed1ab_0 conda-forge jaraco.classes 3.3.0 pyhd8ed1ab_0 conda-forge jeepney 0.8.0 pyhd8ed1ab_0 conda-forge jsonschema 4.17.3 pyhd8ed1ab_0 conda-forge keyring 24.2.0 py311h38be061_1 conda-forge lame 3.100 h166bdaf_1003 conda-forge lcms2 2.15 haa2dc70_1 conda-forge ld_impl_linux-64 2.40 h41732ed_0 conda-forge lerc 4.0.0 h27087fc_0 conda-forge libass 0.17.1 h8fe9dca_1 conda-forge libblas 3.9.0 19_linux64_openblas conda-forge libcblas 3.9.0 19_linux64_openblas conda-forge libdeflate 1.18 h0b41bf4_0 conda-forge libdrm 2.4.114 h166bdaf_0 conda-forge libexpat 2.5.0 hcb278e6_1 conda-forge libffi 3.4.2 h7f98852_5 conda-forge libgcc-ng 13.2.0 h807b86a_2 conda-forge libgfortran-ng 13.2.0 h69a702a_2 conda-forge libgfortran5 13.2.0 ha4646dd_2 conda-forge libglib 2.78.0 hebfc3b9_0 conda-forge libgomp 13.2.0 h807b86a_2 conda-forge libiconv 1.17 h166bdaf_0 conda-forge libidn2 2.3.4 h166bdaf_0 conda-forge libjpeg-turbo 2.1.5.1 hd590300_1 conda-forge liblapack 3.9.0 19_linux64_openblas conda-forge libnsl 2.0.1 hd590300_0 conda-forge libopenblas 0.3.24 pthreads_h413a1c8_0 conda-forge libopus 1.3.1 h7f98852_1 conda-forge libpciaccess 0.17 h166bdaf_0 conda-forge libpng 1.6.39 h753d276_0 conda-forge libsqlite 3.44.0 h2797004_0 conda-forge libstdcxx-ng 13.2.0 h7e041cc_2 conda-forge libtasn1 4.19.0 h166bdaf_0 conda-forge libtiff 4.5.1 h8b53f26_1 conda-forge libunistring 0.9.10 h7f98852_0 conda-forge libuuid 2.38.1 h0b41bf4_0 conda-forge libva 2.20.0 hd590300_0 conda-forge libvpx 1.13.1 h59595ed_0 conda-forge libwebp-base 1.3.2 hd590300_0 conda-forge libxcb 1.15 h0b41bf4_0 conda-forge libxml2 2.11.5 h232c23b_1 conda-forge libzlib 1.2.13 hd590300_5 conda-forge manim 0.17.3 pyhd8ed1ab_0 conda-forge manimpango 0.4.4 py311h5fe2a17_1 conda-forge mapbox_earcut 1.0.1 py311h9547e67_0 conda-forge markdown-it-py 3.0.0 pyhd8ed1ab_0 conda-forge mdurl 0.1.0 pyhd8ed1ab_0 conda-forge moderngl 5.8.2 py311h320fe9a_1 conda-forge moderngl-window 2.4.1 pyhd8ed1ab_0 conda-forge more-itertools 10.1.0 pyhd8ed1ab_0 conda-forge msgpack-python 1.0.6 py311h9547e67_0 conda-forge multipledispatch 0.6.0 py_0 conda-forge ncurses 6.4 h59595ed_2 conda-forge nettle 3.8.1 hc379101_1 conda-forge networkx 2.8.8 pyhd8ed1ab_0 conda-forge numpy 1.26.0 py311h64a7726_0 conda-forge openh264 2.3.1 hcb278e6_2 conda-forge openjpeg 2.5.0 hfec8fc6_2 conda-forge openssl 3.1.4 hd590300_0 conda-forge p11-kit 0.24.1 hc5aa10d_0 conda-forge packaging 23.2 pyhd8ed1ab_0 conda-forge pango 1.50.14 ha41ecd1_2 conda-forge pcre2 10.40 hc3806b6_0 conda-forge pexpect 4.8.0 pyh1a96a4e_2 conda-forge pillow 9.5.0 py311h0b84326_1 conda-forge pip 23.3.1 pyhd8ed1ab_0 conda-forge pixman 0.42.2 h59595ed_0 conda-forge pkginfo 1.9.6 pyhd8ed1ab_0 conda-forge pkgutil-resolve-name 1.3.10 pyhd8ed1ab_1 conda-forge platformdirs 3.11.0 pyhd8ed1ab_0 conda-forge poetry 1.6.1 linux_pyha804496_0 conda-forge poetry-core 1.7.0 pyhd8ed1ab_0 conda-forge poetry-plugin-export 1.6.0 pyhd8ed1ab_0 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge pycairo 1.25.1 py311h8feb60e_0 conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pydub 0.25.1 pyhd8ed1ab_0 conda-forge pyglet 1.5.27 py311h38be061_4 conda-forge pygments 2.16.1 pyhd8ed1ab_0 conda-forge pyproject_hooks 1.0.0 pyhd8ed1ab_0 conda-forge pyrr 0.10.3 py_0 conda-forge pyrsistent 0.20.0 py311h459d7ec_0 conda-forge pysocks 1.7.1 pyha2e5f31_6 conda-forge python 3.11.6 hab00c5b_0_cpython conda-forge python-build 0.10.0 pyhd8ed1ab_1 conda-forge python-installer 0.7.0 pyhd8ed1ab_0 conda-forge python_abi 3.11 4_cp311 conda-forge pyyaml 6.0.1 py311h459d7ec_1 conda-forge rapidfuzz 3.4.0 py311hb755f60_0 conda-forge readline 8.2 h8228510_1 conda-forge requests 2.31.0 pyhd8ed1ab_0 conda-forge requests-toolbelt 1.0.0 pyhd8ed1ab_0 conda-forge rich 13.6.0 pyhd8ed1ab_0 conda-forge scipy 1.11.3 py311h64a7726_1 conda-forge screeninfo 0.8.1 py311h38be061_1 conda-forge secretstorage 3.3.3 py311h38be061_2 conda-forge setuptools 68.2.2 pyhd8ed1ab_0 conda-forge shellingham 1.5.4 pyhd8ed1ab_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge skia-pathops 0.7.4 py311h4dd048b_0 conda-forge srt 3.5.3 py311h38be061_0 conda-forge svgelements 1.9.6 pyhd8ed1ab_0 conda-forge svt-av1 1.4.1 hcb278e6_0 conda-forge tk 8.6.13 h2797004_0 conda-forge tomli 2.0.1 pyhd8ed1ab_0 conda-forge tomlkit 0.12.1 pyha770c72_0 conda-forge tqdm 4.66.1 pyhd8ed1ab_0 conda-forge trove-classifiers 2023.10.18 pyhd8ed1ab_0 conda-forge typing-extensions 4.8.0 hd8ed1ab_0 conda-forge typing_extensions 4.8.0 pyha770c72_0 conda-forge tzdata 2023c h71feb2d_0 conda-forge urllib3 2.0.7 pyhd8ed1ab_0 conda-forge virtualenv 20.24.6 pyhd8ed1ab_0 conda-forge watchdog 2.3.1 py311h38be061_0 conda-forge wheel 0.41.3 pyhd8ed1ab_0 conda-forge x264 1!164.3095 h166bdaf_2 conda-forge x265 3.5 h924138e_3 conda-forge xorg-fixesproto 5.0 h7f98852_1002 conda-forge xorg-kbproto 1.0.7 h7f98852_1002 conda-forge xorg-libice 1.1.1 hd590300_0 conda-forge xorg-libsm 1.2.4 h7391055_0 conda-forge xorg-libx11 1.8.7 h8ee46fc_0 conda-forge xorg-libxau 1.0.11 hd590300_0 conda-forge xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge xorg-libxext 1.3.4 h0b41bf4_2 conda-forge xorg-libxfixes 5.0.3 h7f98852_1004 conda-forge xorg-libxrender 0.9.11 hd590300_0 conda-forge xorg-renderproto 0.11.1 h7f98852_1002 conda-forge xorg-xextproto 7.3.0 h0b41bf4_1003 conda-forge xorg-xproto 7.0.31 h7f98852_1007 conda-forge xz 5.2.6 h166bdaf_0 conda-forge yaml 0.2.5 h7f98852_2 conda-forge zipp 3.17.0 pyhd8ed1ab_0 conda-forge zlib 1.2.13 hd590300_5 conda-forge zstd 1.5.5 hfc55251_0 conda-forge ```
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): extra/texlive-bin 2023.66984-16 + Installed LaTeX packages: [tex_packages.txt](https://github.com/ManimCommunity/manim/files/13232428/tex_packages.txt)
FFMPEG Output of `ffmpeg -version`: ``` ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13.2.1 (GCC) 20230801 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-version3 --enable-vulkan libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100 ```
behackl commented 10 months ago

Duplicate of #3403, running pip install -U --force manimpango should fix the issue. Will also be fixed with the upcoming release.

alexk101 commented 10 months ago

I see @behackl . Thanks for the answer. I think that this is almost certainly the same bug, but I am also a bit curious why the type error only fired on the second text object and not the first. Also, do you have any idea what the release timeline looks like? I prefer the manage dependencies with conda as much as possible, and only use pip if absolutely necessary.