Skip to content

importing manim should not trigger pygments.styles.get_all_styles #3713

Closed
@astro-angelfish

Description

@astro-angelfish

Upon running import manim, and in particular during the initialization of manim.mobject.text.code_mobject.Code, a styles_list attribute is populated with the output of pygments.styles.get_all_styles().

This causes a lot of overhead and can lead to serious breakage (as documented by the original report below).

Tasks:

  • remove the Code.styles_list attribute,
  • rewrite the documentation to say that a list of all styles can be geneated by calling pygments.styles.get_all_styles yourself,
  • the example in the docstring of Code should be rewritten to not use Code.styles_list[15], but instead the explicit name of a code style.

Original report:

Description of bug / unexpected behavior

I tried to make a video and wanted to see the demo by manim -pql scene.py MemoryMapping. But it fails with an exception.

I also tried to do sudo pacman -Rscn cython as others say that cython uses gdb but did nothing useful.

Expected behavior

The command works correctly and gives me a video

How to reproduce the issue

Code for reproducing the problem
from manim import *

class MemoryMapping(Scene):
    def construct(self):
        phy_mem_all = Reactangle(width=2.0, height=4.0)
        self.play(Create(phy_mem_all))

Additional media files

Images/GIFs

I have no media because nothing succeed.

Logs

Terminal output
Traceback (most recent call last):
  File "/usr/bin/manim", line 5, in <module>
    from manim.__main__ import main
  File "/usr/lib/python3.11/site-packages/manim/__init__.py", line 68, in <module>
    from .mobject.text.code_mobject import *
  File "/usr/lib/python3.11/site-packages/manim/mobject/text/code_mobject.py", line 30, in <module>
    class Code(VGroup):
  File "/usr/lib/python3.11/site-packages/manim/mobject/text/code_mobject.py", line 158, in Code
    styles_list = list(get_all_styles())
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pygments/styles/__init__.py", line 60, in get_all_styles
    for name, _ in find_plugin_styles():
  File "/usr/lib/python3.11/site-packages/pygments/plugin.py", line 83, in find_plugin_styles
    yield entrypoint.name, entrypoint.load()
                           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/voltron/__init__.py", line 95, in <module>
    setup_env()
  File "/usr/lib/python3.11/site-packages/voltron/__init__.py", line 24, in setup_env
    env = Environment(setup_logging=False,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/scruffy/env.py", line 49, in __init__
    self.add(**kwargs)
  File "/usr/lib/python3.11/site-packages/scruffy/env.py", line 114, in add
    self._children[key].prepare()
  File "/usr/lib/python3.11/site-packages/scruffy/file.py", line 439, in prepare
    self.load()
  File "/usr/lib/python3.11/site-packages/scruffy/file.py", line 445, in load
    self._pm.load_plugins(self.path)
  File "/usr/lib/python3.11/site-packages/scruffy/plugin.py", line 65, in load_plugins
    self.load_plugins(filepath)
  File "/usr/lib/python3.11/site-packages/scruffy/plugin.py", line 61, in load_plugins
    mod = imp.load_module(modname, file, path, descr)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/imp.py", line 235, in load_module
    return load_source(name, filename, file)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/imp.py", line 172, in load_source
    module = _load(spec)
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/voltron/plugins/debugger/dbg_gdb.py", line 663, in <module>
    class GDBCommand(DebuggerCommand, gdb.Command):
                                      ^^^^^^^^^^^
AttributeError: module 'gdb' has no attribute 'Command'

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Linux AL-1S 6.8.7-arch1-1 Update ReadMe to provide clarity... #1 SMP PREEMPT_DYNAMIC Wed, 17 Apr 2024 15:20:28 +0000 x86_64 GNU/Linux
  • RAM: 16G
  • Python version (python/py/python3 --version): Python 3.11.8
  • Installed modules (provide output from pip list):
    https://pastebin.com/TzLmr6nV
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020): texlive-basic 2024.2-1
  • Installed LaTeX packages:

tlmgrlist.txt

FFMPEG

Output of ffmpeg -version:

ffmpeg version n6.1.1 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-frei0r --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-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --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-vapoursynth --enable-version3 --enable-vulkan
libavutil      58. 29.100 / 58. 29.100
libavcodec     60. 31.102 / 60. 31.102
libavformat    60. 16.100 / 60. 16.100
libavdevice    60.  3.100 / 60.  3.100
libavfilter     9. 12.100 /  9. 12.100
libswscale      7.  5.100 /  7.  5.100
libswresample   4. 12.100 /  4. 12.100
libpostproc    57.  3.100 / 57.  3.100

Additional comments

I also installed blackarch on the top of archlinux. so there are a lot of packages. blackarch might have packages that causes the error but i didn't find anything useful. Manim was installed via paru -S manim

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersmaintenancerefactoring, typos, removing clutter/dead code, and other code quality improvements

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions