Open kyunghoon-han opened 2 years ago
Please provide the full traceback, thanks.
Hello,
Thank you very much for the reply. The following is the full traceback of the error.
Manim Community v0.15.1
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/cli/render/commands │
│ .py:141 in render │
│ │
│ 138 │ │ for SceneClass in scene_classes_from_file(file): │
│ 139 │ │ │ try: │
│ 140 │ │ │ │ scene = SceneClass() │
│ ❱ 141 │ │ │ │ scene.render() │
│ 142 │ │ │ except Exception: │
│ 143 │ │ │ │ error_console.print_exception() │
│ 144 │ │ │ │ sys.exit(1) │
│ /Users/khan/mambaforge/lib/python3.9/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: │
│ │
│ /Users/khan/fun_codes/manim_tutorial/project/fonts.py:6 in construct │
│ │
│ 3 │
│ 4 class FontsExample(Scene): │
│ 5 │ def construct(self): │
│ ❱ 6 │ │ ft1 = Text("Noto Sans", font="Noto Sans") │
│ 7 │ │ self.add(ft1) │
│ 8 │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/text/text_m │
│ object.py:478 in __init__ │
│ │
│ 475 │ │ color = Color(color) if color else VMobject().color │
│ 476 │ │ file_name = self._text2svg(color) │
│ 477 │ │ PangoUtils.remove_last_M(file_name) │
│ ❱ 478 │ │ super().__init__( │
│ 479 │ │ │ file_name, │
│ 480 │ │ │ fill_opacity=fill_opacity, │
│ 481 │ │ │ stroke_width=stroke_width, │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/svg/svg_mob │
│ ject.py:109 in __init__ │
│ │
│ 106 │ │ │ fill_opacity, │
│ 107 │ │ │ stroke_opacity, │
│ 108 │ │ ) │
│ ❱ 109 │ │ super().__init__( │
│ 110 │ │ │ color=color, │
│ 111 │ │ │ fill_opacity=fill_opacity, │
│ 112 │ │ │ stroke_width=stroke_width, │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/types/vecto │
│ rized_mobject.py:116 in __init__ │
│ │
│ 113 │ │ self.shade_in_3d = shade_in_3d │
│ 114 │ │ self.tolerance_for_point_equality = tolerance_for_point_equal │
│ 115 │ │ self.n_points_per_cubic_curve = n_points_per_cubic_curve │
│ ❱ 116 │ │ super().__init__(**kwargs) │
│ 117 │ │ │
│ 118 │ │ if fill_color: │
│ 119 │ │ │ self.fill_color = fill_color │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/mobject.py: │
│ 106 in __init__ │
│ │
│ 103 │ │ self.color = Color(color) if color else None │
│ 104 │ │ │
│ 105 │ │ self.reset_points() │
│ ❱ 106 │ │ self.generate_points() │
│ 107 │ │ self.init_colors() │
│ 108 │ │
│ 109 │ @classmethod │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/svg/svg_mob │
│ ject.py:156 in generate_points │
│ │
│ 153 │ │ the SVGMobject's points from XML tags, populating self.mobject │
│ 154 │ │ any submobjects within self.mobjects. │
│ 155 │ │ """ │
│ ❱ 156 │ │ doc = minidom_parse(self.file_path) │
│ 157 │ │ for node in doc.childNodes: │
│ 158 │ │ │ if not isinstance(node, MinidomElement) or node.tagName != │
│ 159 │ │ │ │ continue │
│ │
│ /Users/khan/mambaforge/lib/python3.9/xml/dom/minidom.py:1988 in parse │
│ │
│ 1985 │ """Parse a file into a DOM by filename or file object.""" │
│ 1986 │ if parser is None and not bufsize: │
│ 1987 │ │ from xml.dom import expatbuilder │
│ ❱ 1988 │ │ return expatbuilder.parse(file) │
│ 1989 │ else: │
│ 1990 │ │ from xml.dom import pulldom │
│ 1991 │ │ return _do_pulldom_parse(pulldom.parse, (file,), │
│ │
│ /Users/khan/mambaforge/lib/python3.9/xml/dom/expatbuilder.py:911 in parse │
│ │
│ 908 │ │
│ 909 │ if isinstance(file, str): │
│ 910 │ │ with open(file, 'rb') as fp: │
│ ❱ 911 │ │ │ result = builder.parseFile(fp) │
│ 912 │ else: │
│ 913 │ │ result = builder.parseFile(file) │
│ 914 │ return result │
│ │
│ /Users/khan/mambaforge/lib/python3.9/xml/dom/expatbuilder.py:211 in │
│ parseFile │
│ │
│ 208 │ │ │ │ if first_buffer and self.document.documentElement: │
│ 209 │ │ │ │ │ self._setup_subset(buffer) │
│ 210 │ │ │ │ first_buffer = False │
│ ❱ 211 │ │ │ parser.Parse(b"", True) │
│ 212 │ │ except ParseEscape: │
│ 213 │ │ │ pass │
│ 214 │ │ doc = self.document │
╰──────────────────────────────────────────────────────────────────────────────╯
Can you show it in context? The command used, traceback, and error received? Just paste the entire command line output.
Hello,
Thank you again and sorry that I forgot to include the other necessary details. In short, the command I input was:
manim -pqh fonts.py
and the error I didn't include in the previous comment is
ExpatError: no element found: line 1, column 0
Exact copy of the entire command line output is:
khan ~/fun_codes/manim_tutorial/project > manim -pqh fonts.py FontsExample
Manim Community v0.15.1
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/cli/render/commands │
│ .py:141 in render │
│ │
│ 138 │ │ for SceneClass in scene_classes_from_file(file): │
│ 139 │ │ │ try: │
│ 140 │ │ │ │ scene = SceneClass() │
│ ❱ 141 │ │ │ │ scene.render() │
│ 142 │ │ │ except Exception: │
│ 143 │ │ │ │ error_console.print_exception() │
│ 144 │ │ │ │ sys.exit(1) │
│ /Users/khan/mambaforge/lib/python3.9/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: │
│ │
│ /Users/khan/fun_codes/manim_tutorial/project/fonts.py:6 in construct │
│ │
│ 3 │
│ 4 class FontsExample(Scene): │
│ 5 │ def construct(self): │
│ ❱ 6 │ │ ft1 = Text("Noto Sans", font="Noto Sans") │
│ 7 │ │ self.add(ft1) │
│ 8 │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/text/text_m │
│ object.py:478 in __init__ │
│ │
│ 475 │ │ color = Color(color) if color else VMobject().color │
│ 476 │ │ file_name = self._text2svg(color) │
│ 477 │ │ PangoUtils.remove_last_M(file_name) │
│ ❱ 478 │ │ super().__init__( │
│ 479 │ │ │ file_name, │
│ 480 │ │ │ fill_opacity=fill_opacity, │
│ 481 │ │ │ stroke_width=stroke_width, │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/svg/svg_mob │
│ ject.py:109 in __init__ │
│ │
│ 106 │ │ │ fill_opacity, │
│ 107 │ │ │ stroke_opacity, │
│ 108 │ │ ) │
│ ❱ 109 │ │ super().__init__( │
│ 110 │ │ │ color=color, │
│ 111 │ │ │ fill_opacity=fill_opacity, │
│ 112 │ │ │ stroke_width=stroke_width, │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/types/vecto │
│ rized_mobject.py:116 in __init__ │
│ │
│ 113 │ │ self.shade_in_3d = shade_in_3d │
│ 114 │ │ self.tolerance_for_point_equality = tolerance_for_point_equal │
│ 115 │ │ self.n_points_per_cubic_curve = n_points_per_cubic_curve │
│ ❱ 116 │ │ super().__init__(**kwargs) │
│ 117 │ │ │
│ 118 │ │ if fill_color: │
│ 119 │ │ │ self.fill_color = fill_color │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/mobject.py: │
│ 106 in __init__ │
│ │
│ 103 │ │ self.color = Color(color) if color else None │
│ 104 │ │ │
│ 105 │ │ self.reset_points() │
│ ❱ 106 │ │ self.generate_points() │
│ 107 │ │ self.init_colors() │
│ 108 │ │
│ 109 │ @classmethod │
│ │
│ /Users/khan/mambaforge/lib/python3.9/site-packages/manim/mobject/svg/svg_mob │
│ ject.py:156 in generate_points │
│ │
│ 153 │ │ the SVGMobject's points from XML tags, populating self.mobject │
│ 154 │ │ any submobjects within self.mobjects. │
│ 155 │ │ """ │
│ ❱ 156 │ │ doc = minidom_parse(self.file_path) │
│ 157 │ │ for node in doc.childNodes: │
│ 158 │ │ │ if not isinstance(node, MinidomElement) or node.tagName != │
│ 159 │ │ │ │ continue │
│ │
│ /Users/khan/mambaforge/lib/python3.9/xml/dom/minidom.py:1988 in parse │
│ │
│ 1985 │ """Parse a file into a DOM by filename or file object.""" │
│ 1986 │ if parser is None and not bufsize: │
│ 1987 │ │ from xml.dom import expatbuilder │
│ ❱ 1988 │ │ return expatbuilder.parse(file) │
│ 1989 │ else: │
│ 1990 │ │ from xml.dom import pulldom │
│ 1991 │ │ return _do_pulldom_parse(pulldom.parse, (file,), │
│ │
│ /Users/khan/mambaforge/lib/python3.9/xml/dom/expatbuilder.py:911 in parse │
│ │
│ 908 │ │
│ 909 │ if isinstance(file, str): │
│ 910 │ │ with open(file, 'rb') as fp: │
│ ❱ 911 │ │ │ result = builder.parseFile(fp) │
│ 912 │ else: │
│ 913 │ │ result = builder.parseFile(file) │
│ 914 │ return result │
│ │
│ /Users/khan/mambaforge/lib/python3.9/xml/dom/expatbuilder.py:211 in │
│ parseFile │
│ │
│ 208 │ │ │ │ if first_buffer and self.document.documentElement: │
│ 209 │ │ │ │ │ self._setup_subset(buffer) │
│ 210 │ │ │ │ first_buffer = False │
│ ❱ 211 │ │ │ parser.Parse(b"", True) │
│ 212 │ │ except ParseEscape: │
│ 213 │ │ │ pass │
│ 214 │ │ doc = self.document │
╰──────────────────────────────────────────────────────────────────────────────╯
ExpatError: no element found: line 1, column 0
Assertion failed: (!"reached"), function _cairo_hash_table_lookup_unique_key, file cairo-hash.c, line 251.
This means Cairo/Pango failed to find fonts for some reason. Most probably just restarting the PC should fix this. Try deleting media/
in cwd and run again and report the output.
Hello Naveen,
Thank you for the input & help. I tried your advice exactly on my Mac, but still got the following error:
khan ~/fun_codes/manim_tutorial/project > manim -pqh fonts.py
Manim Community v0.15.1
Assertion failed: (tmp.table_size - hash_table_sizes < ARRAY_LENGTH (hash_table_sizes)), function _cairo_hash_table_manage, file cairo-hash.c, line 286.
[1] 4263 abort manim -pqh fonts.py
I reinstalled Cairo as well, but still gets the same issue.
Thanks again, K
What's is the version of Cairo used? The below snippet should tell you the version.
import manimpango
manimpango.cairo_version()
Also, how did you install Cairo?
Does this snippet run?
import manimpango
print(manimpango.list_fonts())
(if yes, can you paste the output?)
Hello Naveen,
Thank you again. I installed Cairo using Homebrew with:
brew install cairo
The following is the Python code snippet of what I tried:
import manimpango
manimpango.cairo_version()
# output was '1.16.0'
a = manimpango.list_fonts() # this runs alright
print(len(a)) # so there were 316 fonts
for font in a:
if "Noto" in font:
print(font)
''' The following are the ones I found (Noto Sans wasn't found)
Noto Mono for Powerline
Noto Nastaliq Urdu
Noto Sans Anatolian Hieroglyphs
Noto Sans Egyptian Hieroglyphs
Noto Sans Kannada
Noto Sans Myanmar
Noto Sans Oriya
Noto Serif Myanmar
'''
Because I could not find Noto Sans font in the list, I retried the algorithm as below:
from manim import *
import manimpango
class FontsExample(Scene):
def construct(self):
ft1 = Text("Noto Mono for Powerline", font="Noto Mono for Powerline")
self.add(ft1)
However, this still gave me the same error as below:
khan ~/fun_codes/manim_tutorial/project > manim -pqh fonts.py ✔ (mambaforge)
Manim Community v0.15.1
Assertion failed: (tmp.table_size - hash_table_sizes < ARRAY_LENGTH (hash_table_sizes)), function _cairo_hash_table_manage, file cairo-hash.c, line 286.
[1] 7914 abort manim -pqh fonts.py
Does this same error occur with the default font?
from manim import *
class FontsExample(Scene):
def construct(self):
ft = Text("Test")
self.add(ft)
Hello Naveen,
Seems like I am still getting the same error like below:
Assertion failed: (!"reached"), function _cairo_hash_table_lookup_unique_key, file cairo-hash.c, line 251.
[1] 11454 abort manim -pqh fonts.py
Thank you again for the patience
Hmm, I think you would need to report a bug upstream as they may help you better debug it. First, let's check whether we can reproduce this with a C program: https://raw.githubusercontent.com/GNOME/pango/main/examples/cairosimple.c Try downloading and building it by
curl -OL https://raw.githubusercontent.com/GNOME/pango/main/examples/cairosimple.c
gcc cairosimple.c `pkg-config --libs --cflags pangocairo` -o test
./test test.png
And see if the error happens there. If it happens there too please reply.
Thank you for the quick reply.
I just tried it immediately and confused that with GCC it somehow works quite well. (I got a pretty picture with Tests and Salems on as attached :) )
Guess my Python 3 interpreter is experiencing some trouble seeing what my GCC is seeing
(and any advice on how to report a bug upstream? I never tried it)
Thank you again!
I just tried it immediately and confused that with GCC it somehow works quite well.
Hmm, that makes it even more confusing, since you can't report it upstream. They would ask for a C-reproducer.
Maybe GCC finds a different version of Pango and Cairo than what ManimPango was compiled with? I would need the output of the following commands to verify that, run these whichever terminal you used to run manim (I hope you ran that GCC command in the same shell too).
which pkg-config
pkg-config --libs --cflags pangocairo
which python
python --version --version
python -c 'import manimpango; print(manimpango.__file__)'
python -c 'import manim; print(manim.__file__)'
python -c 'import manim; print(manim.pango_version())'
python -c 'import manim; print(manim.cairo_version())'
Hello Naveen,
The last two lines of the suggested code gave me a peculiar error.
First of all the following are the outputs of which pkg-config
and pkg-config --libs --cflags pangocairo
khan ~/fun_codes/manim_tutorial/c_stuff > which pkg-config
/opt/homebrew/bin/pkg-config
pkg-config --libs --cflags pangocairo
-I/opt/homebrew/Cellar/libffi/3.4.2/include -I/opt/homebrew/Cellar/pango/1.50.6/include/pango-1.0 -I/opt/homebrew/Cellar/harfbuzz/4.0.1/include/harfbuzz -I/opt/homebrew/Cellar/pango/1.50.6/include/pango-1.0 -I/opt/homebrew/Cellar/glib/2.70.4/include -I/opt/homebrew/Cellar/fribidi/1.0.11/include/fribidi -I/opt/homebrew/Cellar/harfbuzz/4.0.1/include/harfbuzz -I/opt/homebrew/Cellar/graphite2/1.3.14/include -I/opt/homebrew/Cellar/cairo/1.16.0_5/include/cairo -I/opt/homebrew/Cellar/glib/2.70.4/include -I/opt/homebrew/Cellar/glib/2.70.4/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.70.4/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.45/include -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/fontconfig/2.13.1/include -I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/libxcb/1.14_2/include -I/opt/homebrew/Cellar/libxrender/0.9.10/include -I/opt/homebrew/Cellar/libxext/1.3.4/include -I/opt/homebrew/Cellar/libx11/1.7.3.1/include -I/opt/homebrew/Cellar/libxcb/1.14_2/include -I/opt/homebrew/Cellar/libxau/1.0.9/include -I/opt/homebrew/Cellar/libxdmcp/1.1.3/include -I/opt/homebrew/Cellar/xorgproto/2021.5/include -L/opt/homebrew/Cellar/pango/1.50.6/lib -L/opt/homebrew/Cellar/glib/2.70.4/lib -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/Cellar/harfbuzz/4.0.1/lib -L/opt/homebrew/Cellar/cairo/1.16.0_5/lib -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lharfbuzz -lcairo
The following are the results from which python
, python --version --version
and python -c 'import manimpango; print(manimpango.__file__)'
.
khan ~/fun_codes/manim_tutorial/c_stuff > python --version --version
Python 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 05:00:30)
[Clang 11.0.1 ]
khan ~/fun_codes/manim_tutorial/c_stuff > python -c 'import manimpango; print(manimpango.__file__)'
/Users/khan/mambaforge/lib/python3.9/site-packages/manimpango/__init__.py
Now the following are the ones I got the errors from.
khan ~/fun_codes/manim_tutorial/c_stuff > python -c 'import manim; print(manim.pango_version())'
Manim Community v0.15.1
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'manim' has no attribute 'pango_version'
khan ~/fun_codes/manim_tutorial/c_stuff > python -c 'import manim; print(manim.pango_version())'
Guess some parts of Manim is not installed properly on my Mac?
Thank you again.
Now the following are the ones I got the errors from.
It's me who typed it wrong, it should be
python -c 'import manimpango; print(manimpango.pango_version())'
python -c 'import manimpango; print(manimpango.cairo_version())'
From the other things I noticed, do you conda-forge
python by default? Can you run pip install manimpango --force --no-binary :all:
and see if that fixes the problem (it recompiles the binding, maybe it should work)? Can you also try install Manim on homebrew provided Python?
Hello Naveen,
Sorry for the late response to the comment. I just tried the commands you suggested, and I got:
khan ~/fun_codes/manim_tutorial > python -c 'import manimpango; print(manimpango.pango_version())'
1.50.6
khan ~/fun_codes/manim_tutorial > python -c 'import manimpango; print(manimpango.cairo_version())'
1.16.0
I do use conda-forge
by default as well.
And I did try the
pip install manimpango --force --no-binary :all:
as well, but didn't solve the problem.
And... it might be a very silly question, but how do I install Manim on homebrew provided python?
Thank you again!
@kyunghoon-han any solution you found ? I faced exact same problem today.
@naveen521kk
I tried everything @naveen521kk suggested and the results are exactly what @kyunghoon-han reported. I am on M2 MacBook Air.
Hello, sorry for the late reply... Seems like it is not compatible with M1 or M2... I tried on my M1 back then with failure (I stuck to my old iMac instead, which works alright) and my friend with M2 also have the same issue...
Any idea on how to solve it by any chance?
try setting and environment variable PANGOCAIRO_BACKEND=fontconfig
and see if the error occurs, you can use that as a workaround. I'm not sure what exactly is the root cause of this issue.
@naveen521kk Nope, I get the same error.
Manim Community v0.16.0.post0
Assertion failed: (!"reached"), function _cairo_hash_table_lookup_unique_key, file cairo-hash.c, line 251.
zsh: abort PANGOCAIRO_BACKEND=fontconfig python -m manim -pqm te.py RenderText
once media/
folder is created I get the other error (not copying the whole traceback, you've seen it before from @kyunghoon-han )
│ 208 │ │ │ │ if first_buffer and self.document.documentElement: │
│ 209 │ │ │ │ │ self._setup_subset(buffer) │
│ 210 │ │ │ │ first_buffer = False │
│ ❱ 211 │ │ │ parser.Parse(b"", True) │
│ 212 │ │ except ParseEscape: │
│ 213 │ │ │ pass │
│ 214 │ │ doc = self.document │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ExpatError: no element found: line 1, column 0
@naveen521kk @kyunghoon-han I finally got manim
working with Text(..)
on M2. So far I was using conda
env. But now I switched to using the system python and used venv
. That seemed to solve the problem. I installed all libraries same way as before. Although I am not 100% sure if environment switching is indeed responsible for the fix. If I will investigate further and post here.
Description of bug / unexpected behavior
Hello all,
I was following the tutorial provided by the Manim Community web-page, and noticed that somehow Cairo was not behaving as I expected...
The following is the code I copied from the tutorial
and the following is the error message I received: Assertion failed: (!"reached"), function _cairo_hash_table_lookup_unique_key, file cairo-hash.c, line 251.
Any idea on how this problem can be resolved?
Thank you in advance,
Best, K
System specifications
System Details
- OS : MacOS M1 Monterey - RAM: 8 GB - Python version (`python/py/python3 --version`): Python 3.9.2 - Installed modules (provide output from `pip list`):LaTeX details
+ LaTeX distribution : TexLive 2021FFMPEG
Output of `ffmpeg -version`: ffmpeg version 4.3.1 built with clang version 11.0.0 Thank you very much for the help in advance. Best, K