3b1b / manim

Animation engine for explanatory math videos
MIT License
70.62k stars 6.22k forks source link

Error creating scene on Windows 10 #353

Closed Tarang74 closed 1 year ago

Tarang74 commented 5 years ago

Using the tutorial from talkingphysics.com

Using:

python extract_scene.py example_scenes.py SquareToCircle -p

Traceback (most recent call last): File "extract_scene.py", line 15, in from scene.scene import Scene File "C:\Users######\manim\scene\scene.py", line 17, in from camera.camera import Camera File "C:\Users#######\manim\camera\camera.py", line 10, in import cairo ModuleNotFoundError: No module named 'cairo'

eulertour commented 5 years ago

pycairo isn't installed. You should run pip install -r requirements.txt.

Tarang74 commented 5 years ago

pycairo isn't installed. You should run pip install -r requirements.txt.

I have, it says failed to build wheels in the cmd. I’m using windows 10, apparently that’s the problem for many users?

eulertour commented 5 years ago

Can you post what you ran and the output?

Tarang74 commented 5 years ago

Ran the script you showed me; Everything worked fine (requirements already met), except for the last install - which was pycairo

Collecting pycairo==1.17.1 (from -r requirements.txt (line 9))
  Using cached https://files.pythonhosted.org/packages/68/76/340ff847897296b2c8174dfa5a5ec3406e3ed783a2abac918cf326abad86/pycairo-1.17.1.tar.gz
Building wheels for collected packages: pycairo
  Running setup.py bdist_wheel for pycairo ... error
  Complete output from command C:\Users\#####\AppData\Local\conda\conda\envs\manim\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\#####\\AppData\\Local\\Temp\\pip-install-4zufmmdw\\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\#####\AppData\Local\Temp\pip-wheel-j2huvj4g --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
  creating build\temp.win-amd64-3.7
  creating build\temp.win-amd64-3.7\Release
  creating build\temp.win-amd64-3.7\Release\cairo
  cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DPYCAIRO_VERSION_MAJOR=1 -DPYCAIRO_VERSION_MINOR=17 -DPYCAIRO_VERSION_MICRO=1 -IC:\Users\#####\AppData\Local\conda\conda\envs\manim\include -IC:\Users\#####\AppData\Local\conda\conda\envs\manim\include "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /Tccairo/device.c /Fobuild\temp.win-amd64-3.7\Release\cairo/device.obj
  error: command 'cl.exe' failed: No such file or directory

  ----------------------------------------
  Failed building wheel for pycairo
  Running setup.py clean for pycairo
Failed to build pycairo
Installing collected packages: pycairo
  Running setup.py install for pycairo ... error
    Complete output from command C:\Users\#####\AppData\Local\conda\conda\envs\manim\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\#####\\AppData\\Local\\Temp\\pip-install-4zufmmdw\\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\#####\AppData\Local\Temp\pip-record-9jdxvvvr\install-record.txt --single-version-externally-managed --compile:
    running install
    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
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    creating build\temp.win-amd64-3.7\Release\cairo
    cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DPYCAIRO_VERSION_MAJOR=1 -DPYCAIRO_VERSION_MINOR=17 -DPYCAIRO_VERSION_MICRO=1 -IC:\Users\#####\AppData\Local\conda\conda\envs\manim\include -IC:\Users\#####\AppData\Local\conda\conda\envs\manim\include "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /Tccairo/device.c /Fobuild\temp.win-amd64-3.7\Release\cairo/device.obj
    error: command 'cl.exe' failed: No such file or directory

    ----------------------------------------
Command "C:\Users\#####\AppData\Local\conda\conda\envs\manim\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\#####\\AppData\\Local\\Temp\\pip-install-4zufmmdw\\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\#####\AppData\Local\Temp\pip-record-9jdxvvvr\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\#####\AppData\Local\Temp\pip-install-4zufmmdw\pycairo\
eulertour commented 5 years ago

I don't know a "best" solution for this, but there seem to be two viable options:

  1. Verify your installation of MS Visual C++, and that cl.exe is added to the PATH environment variable [1][2]
  2. Install from the prebuilt wheels that the University of California Irvine has kindly hosted [wheels] [installation]. These wheels aren't the same version that is specified in requirements.txt, but hopefully they're similar enough. Please post here if you manage to figure this out, as I don't have an easy way to test Windows at the moment.
Tarang74 commented 5 years ago

1 I didn't understand what you meant. -- which path? -- also MS VC is not located anywhere locatable.

2 I tried

I have tried installing pycairo from the UCI website, but it gives me the same result.

2b The wheels script;

pip install https://download.lfd.uci.edu/pythonlibs/gjr6o2id/pycairo-1.15.4-cp36-cp36m-win_amd64.whl outputs this message pycairo-1.15.4-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform

eulertour commented 5 years ago

It looks like you're trying to install a python 3.6 wheel on python 3.7 (note the cp36 in the name). Try downloading a python 3.7 wheel from here and installing it like this.

Tarang74 commented 5 years ago

Thanks, I'll try it now.

Tarang74 commented 5 years ago

Should I activate manim, or use base? (anaconda 3)

Tarang74 commented 5 years ago

Also, the wheel required is pycairo 1.17.1, should I use that version or the latest one (1.18.0)?

eulertour commented 5 years ago

I'm not very familiar with anaconda, but I think you have to activate the environment in order for manim to find it. Using 1.18 rather than 1.17 is probably fine.

Tarang74 commented 5 years ago

What do you use?

Tarang74 commented 5 years ago

I'm actually just learning python so I'm not too familiar with how it all works yet.

Tarang74 commented 5 years ago

Well, I think cairo is working now, I downloaded an offline version and installed it from pip install C:\Users\#####\Desktop\pycairo-1.18.0-cp37-cp37m-win_amd64.whl (it installed successfully)

BUT now there is another error.

C:\Users\#####\manim>python extract_scene.py example_scenes.py SquareToCircle -pl

Writing to C:\Users\#####\Videos/Manim Animations\animations\example_scenes\480p15\SquareToCircleTemp.mp4

Traceback (most recent call last):
  File "extract_scene.py", line 289, in main
    handle_scene(SceneClass(**scene_kwargs), **config)
  File "C:\Users\#####\manim\scene\scene.py", line 69, in __init__
    self.open_movie_pipe()
  File "C:\Users\#####\manim\scene\scene.py", line 627, in open_movie_pipe
    self.writing_process = sp.Popen(command, stdin=sp.PIPE)
  File "C:\Users\#####\AppData\Local\conda\conda\envs\manim\lib\subprocess.py", line 769, in __init__
    restore_signals, start_new_session)
  File "C:\Users\#####\AppData\Local\conda\conda\envs\manim\lib\subprocess.py", line 1172, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

The system cannot find the path specified.
eulertour commented 5 years ago

That's a fairly common error with manim and usually means that ffmpeg isn't installed or isn't installed correctly. I'd recommend searching the issues in this repo for more context.

Tarang74 commented 5 years ago

I have installed everything stated in the repo by Grant.

Tarang74 commented 5 years ago

I can get the -sto save images, but that's all.

Tarang74 commented 5 years ago

Do you know how I can change what frame of the animation I can save, I think -s only does the last frame.

eulertour commented 5 years ago

It seems that python can't find where ffmpeg is installed. It may help to edit the code to print command before it's passed to sp.Popen().

Tarang74 commented 5 years ago

Can you explain more?

eulertour commented 5 years ago

The error is being caused here:

File "C:\Users\#####\manim\scene\scene.py", line 627, in open_movie_pipe
    self.writing_process = sp.Popen(command, stdin=sp.PIPE)

Popen() is meant to take a path to an executable (in this case ffmpeg) and execute it. But in this case there's nothing there (The system cannot find the path specified.). If you print command before it's passed to Popen, you can figure out where python is looking and figure out why ffmpeg isn't there.

liyiliuxingyu commented 5 years ago

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo intall it, all thing will be done.