Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Cairo #661

Closed
daniel-lara-ec opened this issue Jul 30, 2019 · 17 comments
Closed

Problems with Cairo #661

daniel-lara-ec opened this issue Jul 30, 2019 · 17 comments

Comments

@daniel-lara-ec
Copy link

Hi, Im tried to install in mi macbook pro computed with MacOS Mojave and i complete this but when i tried the example i have this error

Tests-MacBook-Pro:ManimInstall test$ python3 -m manim example_scenes.py WriteStuff -pl
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/daniellara/ManimInstall/manim.py", line 2, in <module>
    import manimlib
  File "/Users/daniellara/ManimInstall/manimlib/__init__.py", line 4, in <module>
    import manimlib.extract_scene
  File "/Users/daniellara/ManimInstall/manimlib/extract_scene.py", line 9, in <module>
    from manimlib.scene.scene import Scene
  File "/Users/daniellara/ManimInstall/manimlib/scene/scene.py", line 12, in <module>
    from manimlib.camera.camera import Camera
  File "/Users/daniellara/ManimInstall/manimlib/camera/camera.py", line 9, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'
Tests-MacBook-Pro:ManimInstall test$ 
@Elteoremadebeethoven
Copy link
Contributor

Try with this

@daniel-lara-ec
Copy link
Author

This don't work I'm tried to install again and have this mesaage

(base) Tests-MacBook-Pro:ManimInstall test$ brew install cairo
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
wtfutil

Warning: cairo 1.16.0_2 is already installed and up-to-date
To reinstall 1.16.0_2, run `brew reinstall cairo

but i try to run the code and have the same error

(base) Tests-MacBook-Pro:ManimInstall test$ python3 -m manim example_scenes.py -pl
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/daniellara/Documents/ManimInstall/manim.py", line 2, in <module>
    import manimlib
  File "/Users/daniellara/Documents/ManimInstall/manimlib/__init__.py", line 4, in <module>
    import manimlib.extract_scene
  File "/Users/daniellara/Documents/ManimInstall/manimlib/extract_scene.py", line 9, in <module>
    from manimlib.scene.scene import Scene
  File "/Users/daniellara/Documents/ManimInstall/manimlib/scene/scene.py", line 12, in <module>
    from manimlib.camera.camera import Camera
  File "/Users/daniellara/Documents/ManimInstall/manimlib/camera/camera.py", line 9, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'

@Elteoremadebeethoven
Copy link
Contributor

I see what the error is, you are using a virtual environment (I guess it is virtualenv), in your first comment you were not using it.

First comment:

Tests-MacBook-Pro:ManimInstall test$ python3 -m manim example_scenes.py WriteStuff -pl

Second comment:

(base) Tests-MacBook-Pro:ManimInstall test$ python3 -m manim example_scenes.py -pl

If you are going to use a virtual environment you must reinstall all the python packages with pip. In your case:

(base) Tests-MacBook-Pro:ManimInstall test$ python3 -m pip install -r requirements.txt
(base) Tests-MacBook-Pro:ManimInstall test$ python3 -m pip install pyreadline
(base) Tests-MacBook-Pro:ManimInstall test$ python3 -m pip install pydub

@daniel-lara-ec
Copy link
Author

Yes, I'm using Visual Studio Code. I ran these codes and tried again and terminal showed this

(base) Tests-MacBook-Pro:ManimInstall test$ python -m manim example_scenes.py SquareToCircle -pl
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/daniellara/Documents/ManimInstall/manim.py", line 2, in <module>
    import manimlib
  File "manimlib/__init__.py", line 2, in <module>
    import manimlib.config
  File "manimlib/config.py", line 174
    print(f"Failed to render scene: {str(e)}")
                                            ^
SyntaxError: invalid syntax
(base) Tests-MacBook-Pro:ManimInstall test$ 

@Elteoremadebeethoven
Copy link
Contributor

Elteoremadebeethoven commented Aug 1, 2019

You forgot the 3 in python:

python3 -m manim ...

@daniel-lara-ec
Copy link
Author

Oh! yes i looked this. It's my first time with Python but I uninstall all and try to reinstall again but the problem hold. A friend suggest me that this can be a problem with the path of the modules or something related but i don't kwno how solve this.

I tried again and have this

Tests-MacBook-Pro:manim-master test$ python3 -m manim example_scenes.py WarpSquare -pl
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/daniellara/Downloads/ManimInstall/manim-master/manim.py", line 2, in <module>
    import manimlib
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/__init__.py", line 4, in <module>
    import manimlib.extract_scene
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/extract_scene.py", line 9, in <module>
    from manimlib.scene.scene import Scene
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/scene/scene.py", line 12, in <module>
    from manimlib.camera.camera import Camera
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/camera/camera.py", line 9, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'
Tests-MacBook-Pro:manim-master test$ 

@Elteoremadebeethoven
Copy link
Contributor

The problem is that I do not know if you are trying to install it in the main version of python or in a virtual environment, the last comment you are no longer in virtualenv:

Tests-MacBook-Pro:manim-master test$ python3 -m manim example_scenes.py WarpSquare -pl

You are no longer in the environment (base), as in the previous ones. If you want to install manim in the main version of python then install the pip packages again, BUT without the virtualenv:

Tests-MacBook-Pro:ManimInstall test$ python3 -m pip install -r requirements.txt
Tests-MacBook-Pro:ManimInstall test$ python3 -m pip install pyreadline
Tests-MacBook-Pro:ManimInstall test$ python3 -m pip install pydub

@daniel-lara-ec
Copy link
Author

daniel-lara-ec commented Aug 2, 2019

Well I'm using Visual Studio Code like a terminal
Screen Shot 2019-08-01 at 7 18 02 PM

I tryng to solve this problem using

import cairocffi as cairo

but the problem holds

@Elteoremadebeethoven
Copy link
Contributor

Try this, go to manimlib/camera/camera.py line 9 in your manim-master folder and replace that line with import cairocffi as cairo

@daniel-lara-ec
Copy link
Author

I tried this but i have another problem

Tests-MacBook-Pro:manim-master test$ python3 -m manim example_scenes.py WarpSquare -pl
Media will be written to ./media/. You can change this behavior with the --media_dir flag.

Tests-MacBook-Pro:manim-master test$ python3 -m manim example_scenes.py WarpSquare -pl
Media will be written to ./media/. You can change this behavior with the --media_dir flag.

Traceback (most recent call last):
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/extract_scene.py", line 155, in main
    scene = SceneClass(**scene_kwargs)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/scene/scene.py", line 53, in __init__
    self.construct()
  File "example_scenes.py", line 94, in construct
    square
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/scene/scene.py", line 406, in wrapper
    func(self, *args, **kwargs)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/scene/scene.py", line 463, in play
    self.progress_through_animations(animations)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/scene/scene.py", line 438, in progress_through_animations
    self.update_frame(moving_mobjects, static_image)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/scene/scene.py", line 140, in update_frame
    self.capture_mobjects_in_camera(mobjects, **kwargs)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/scene/scene.py", line 118, in capture_mobjects_in_camera
    self.camera.capture_mobjects(mobjects, **kwargs)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/camera/camera.py", line 269, in capture_mobjects
    func(batch, self.pixel_array)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/camera/camera.py", line 317, in display_multiple_vectorized_mobjects
    self.display_multiple_non_background_colored_vmobjects(batch, pixel_array)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/camera/camera.py", line 320, in display_multiple_non_background_colored_vmobjects
    ctx = self.get_cairo_context(pixel_array)
  File "/Users/daniellara/Downloads/ManimInstall/manim-master/manimlib/camera/camera.py", line 293, in get_cairo_context
    pw, ph
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/surfaces.py", line 715, in create_for_data
    return cls(format, width, height, data, stride)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/surfaces.py", line 703, in __init__
    % (length, stride * height))
ValueError: Got a 480 bytes buffer, needs at least 1639680.

and in problems window have this

Screen Shot 2019-08-01 at 10 34 04 PM

@Elteoremadebeethoven
Copy link
Contributor

Elteoremadebeethoven commented Aug 2, 2019

I forgot to tell you that you had to install cairocffi, with pip:

brew install cairocffi cffi CairoSVG lxml
python3 -m pip install cairocffi 

And reboot.

@Elteoremadebeethoven
Copy link
Contributor

Elteoremadebeethoven commented Aug 2, 2019

Also check this.

@daniel-lara-ec
Copy link
Author

Hi! I solve this problem with this code

export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/libffi/lib"

and install pycairo

pip install pycairo

Thanks for your help!

@Jefferson122
Copy link

Jefferson122 commented Apr 17, 2020

Hi, Im tried to install in mi macbook pro computed with Windows 10 and i complete this but when i tried the example i have this error

C:\Users\57316\Documents\GitHub\manim>python -m example_scenes.py
Traceback (most recent call last):
File "C:\Users\57316\AppData\Local\Continuum\anaconda3\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\57316\AppData\Local\Continuum\anaconda3\lib\runpy.py", line 109, in get_module_details
import(pkg_name)
File "C:\Users\57316\Documents\GitHub\manim\example_scenes.py", line 3, in
from manimlib.imports import *
File "C:\Users\57316\Documents\GitHub\manim\manimlib_init
.py", line 4, in
import manimlib.extract_scene
File "C:\Users\57316\Documents\GitHub\manim\manimlib\extract_scene.py", line 9, in
from manimlib.scene.scene import Scene
File "C:\Users\57316\Documents\GitHub\manim\manimlib\scene\scene.py", line 12, in
from manimlib.camera.camera import Camera
File "C:\Users\57316\Documents\GitHub\manim\manimlib\camera\camera.py", line 9, in
import cairo
ModuleNotFoundError: No module named 'cairo'

@Jefferson122
Copy link

Jefferson122 commented Apr 17, 2020

pip install pycairo
Collecting pycairo
Using cached https://files.pythonhosted.org/packages/e8/9d/c8be300fc6b1298559d37a071c3833b0b251e0fff334d2e4c408d5789162/pycairo-1.19.1.tar.gz
Building wheels for collected packages: pycairo
Building wheel for pycairo (setup.py) ... error
Complete output from command C:\Users\57316\AppData\Local\Continuum\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\57316\AppData\Local\Temp\pip-install-9b0fel7m\pycairo\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\57316\AppData\Local\Temp\pip-wheel-mhk6l4qx --python-tag cp37:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\cairo
copying cairo_init_.py -> build\lib.win-amd64-3.7\cairo
copying cairo_init_.pyi -> build\lib.win-amd64-3.7\cairo
copying cairo\py.typed -> build\lib.win-amd64-3.7\cairo
running build_ext
building 'cairo._cairo' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/


Command "C:\Users\57316\AppData\Local\Continuum\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\57316\AppData\Local\Temp\pip-install-9b0fel7m\pycairo\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\57316\AppData\Local\Temp\pip-record-wvs_qfw6\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\57316\AppData\Local\Temp\pip-install-9b0fel7m\pycairo\

@RonaldQiao
Copy link

I faced the same error when installing pycario, do I have to install cairocffi first?

eulertour pushed a commit to eulertour/manim-3b1b that referenced this issue Nov 9, 2020
* graph_scene: correct placement of labels

* Update test reference data

* Add test for axes and their labels

* black

* removing commented lines for generation of reference data

Co-authored-by: Leo Torres <[email protected]>

* black

* do not shift labels onto screen

if user wants the label above the y axis, it should go there, even if there is not enough space. they can still choose another placement

* updated test and reference data for test_axes

Co-authored-by: Leo Torres <[email protected]>
@amcrabtree
Copy link

I ran the following line in the terminal of VS Code and then restarted VS Code. Worked for me!

pip install cairocffi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants