3b1b / manim

Animation engine for explanatory math videos
MIT License
60.44k stars 5.71k forks source link

Can't seem to import manimlib or cairo on macOS mojave. #637

Closed chancellorjax closed 5 years ago

chancellorjax commented 5 years ago

Don't know if it's an import error or something else.

1. Steps to reproduce the issue (e.g. the command you ran)

python3 extract_scene.py example_scenes.py SquareToCircle -pl

Ran this in the folder and venv. Get the same error.

2. The unexpected behavior that occurred (e.g. error messages or screenshots)

Traceback (most recent call last):
  File "extract_scene.py", line 9, in <module>
    from manimlib.scene.scene import Scene
  File "/Users/username/Code/ManimInstall/manim_9jul/manimlib/__init__.py", line 4, in <module>
    import manimlib.extract_scene
  File "/Users/username/Code/ManimInstall/manim_9jul/manimlib/extract_scene.py", line 9, in <module>
    from manimlib.scene.scene import Scene
  File "/Users/username/Code/ManimInstall/manim_9jul/manimlib/scene/scene.py", line 11, in <module>
    from manimlib.camera.camera import Camera
  File "/Users/username/Code/ManimInstall/manim_9jul/manimlib/camera/camera.py", line 9, in <module>
    import cairo
  File "/Users/username/Code/ManimInstall/manim_9jul/venv/lib/python3.7/site-packages/cairo/__init__.py", line 1, in <module>
    from ._cairo import *  # noqa: F401,F403
ImportError: dlopen(/Users/username/Code/ManimInstall/manim_9jul/venv/lib/python3.7/site-packages/cairo/_cairo.cpython-37m-darwin.so, 2): Symbol not found: _cairo_font_options_get_variations
  Referenced from: /Users/username/Code/ManimInstall/manim_9jul/venv/lib/python3.7/site-packages/cairo/_cairo.cpython-37m-darwin.so
  Expected in: flat namespace
 in /Users/username/Code/ManimInstall/manim_9jul/venv/lib/python3.7/site-packages/cairo/_cairo.cpython-37m-darwin.so

3. The environment (e.g. operating system and version of manim)

macOS mojave 10.14.5

P.S. This is my first support ticket ever here, so feedback is appreciated.

Kolloom commented 5 years ago

manim has been module-fied so do python3 -m manim example_scenes.py SquareToCircle -pl

What installation guide did you follow?

chancellorjax commented 5 years ago

@Kolloom

I followed Theorem of Beethoven's video install guide and this tutorial. After running python3 -m manim example_scenes.py SquareToCircle -pl, I get the following error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/jagraj/Code/ManimInstall/manim_9jul/manim.py", line 2, in <module>
    import manimlib
  File "/Users/jagraj/Code/ManimInstall/manim_9jul/manimlib/__init__.py", line 4, in <module>
    import manimlib.extract_scene
  File "/Users/jagraj/Code/ManimInstall/manim_9jul/manimlib/extract_scene.py", line 9, in <module>
    from manimlib.scene.scene import Scene
  File "/Users/jagraj/Code/ManimInstall/manim_9jul/manimlib/scene/scene.py", line 11, in <module>
    from manimlib.camera.camera import Camera
  File "/Users/jagraj/Code/ManimInstall/manim_9jul/manimlib/camera/camera.py", line 9, in <module>
    import cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairo/__init__.py", line 1, in <module>
    from ._cairo import *  # noqa: F401,F403
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairo/_cairo.cpython-37m-darwin.so, 2): Symbol not found: _cairo_font_options_get_variations
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairo/_cairo.cpython-37m-darwin.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairo/_cairo.cpython-37m-darwin.so
vbartle commented 5 years ago

I had the same ImportError: dlopen .... Symbol not found and tried running a virtual environment with a downgraded python (3.6 instead of 3.7), then pip installing requirements, pip installing pycairo, and brew installing ffmpeg, and ended up working.

This might not directly be a solution for you, but here's what I used: conda create -n manim3.6 python=3.6 conda activate manim3.6 pip install -r requirements.txt pip install pycairo brew install ffmpeg

chancellorjax commented 5 years ago

@vbartle After running the commands you listed, I get the exact error in response to Kolloom. I'm still seeing Python 3.7 in the /Library/Frameworks version but when I run python -V, it shows 3.6.8. Is that how it's supposed to be?

vbartle commented 5 years ago

Did all of those commands finish successfully?

If you're still seeing import attempts on 3.7, 3.6 isn't being used -- you could try using python instead of python3 in python3 -m manim example_scenes.py SquareToCircle -pl but there are several reasons 3.6 might still not be used.

Kolloom commented 5 years ago

I see that blog post, which was written September last year, referenced a couple times here. The installation guide is no longer applicable on the current code base.

manim uses subprocess and does not make use of those python wrappers.

pip3 install sox
pip3 install ffmpeg
pip3 install latex

Media output now defaults to manim/videos so modification at step 8 is not necessary.

The command to run example scene is outdated. (though it will probably work still)

I am not sure what step10 is modifying.

tex_template.tex shoud work as is from the current repo.

Kolloom commented 5 years ago

https://github.com/3b1b/manim/issues/286 https://github.com/3b1b/manim/issues/420 https://github.com/3b1b/manim/issues/430 https://github.com/3b1b/manim/issues/512

chancellorjax commented 5 years ago

@Kolloom

Thanks for the links.

286: I tried uninstalling and reinstalling Python 3.7. Still get the same errors.

420: Installed pycairo using the commands, no luck.

I uninstalled and reinstalled the contents in requirements.txt. Downgraded numpy to 1.15.0 and scipy to 1.1.0 (the versions required).

After all that, I tried python3 -m manim example_scenes.py SquareToCircle -pl to get a slightly shorter version of the same error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/jagraj/Desktop/manim/manim.py", line 2, in <module>
    import manimlib
  File "/Users/jagraj/Desktop/manim/manimlib/__init__.py", line 4, in <module>
    import manimlib.extract_scene
  File "/Users/jagraj/Desktop/manim/manimlib/extract_scene.py", line 9, in <module>
    from manimlib.scene.scene import Scene
  File "/Users/jagraj/Desktop/manim/manimlib/scene/scene.py", line 11, in <module>
    from manimlib.camera.camera import Camera
  File "/Users/jagraj/Desktop/manim/manimlib/camera/camera.py", line 9, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'

I'm in the process of removing Anaconda to see if that helps.

chancellorjax commented 5 years ago

Uninstalling Anaconda worked! Thanks @Kolloom @vbartle