Including Manim in a requirements.txt

Hey there!

I’m trying to use binder to set up an environment where I can share Jupyter Notebooks that include manim Code so that people who don’t have a local installation of manim can modify and run it themselves.
However I didn’t manage to include manim to the requirements.txt successfully. I tried

manim==0.19.0

as this is the version that I have been using when creating my notebooks locally.
To see the errors I get, just paste GitHub - FelixKrull2/my-first-binder into the URL line at mybinder.org.
Maybe anyone knows how get manim into the binder environment?
Thank you very much in advance!

It seems pangocairo is the issue. Some packages have dependencies that go beyond what pip alone can do and so requirementst.txt is not sufficient. I haven’t investigated enough to say if that is the case here or not. Usually then environment.yml is the better way to go because conda has more access and abilities. Usually is the case. In some cases this isn’t even enough. If I have time to test myself, I may.

Yep, looking at the conda-forge dependencies for that package, one will almost certainly want to go the environment.yml route for binder, specifying a few things like the python major version to improve the solve experience e.g.

# .binder/environment.yml
channels:
  - conda-forge
  - nodefaults
dependencies:
  - manim ==0.19.0
  - python >=3.13,<3.14   # or whatever solves

When using environment.yml, the pip key can be used to bring in other stuff: use this sparingly, and definitely avoid any --editable . things, as that will force a rebuild on every upstream change. This can be handled in postBuild, which runs after the cached environment.yml.

One may also encounter even more deps which are not on conda-forge or PyPI: for these it may be possible to use .binder/apt.txt (one package name per line), but this will slow down the solve by an even larger margin. Do note that python- packages installed this way likely will not be available in the kernel environment.

2 Likes

For future reference, the error is

#21 [15/18] RUN /srv/conda/envs/notebook/bin/pip install --no-cache-dir -r "requirements.txt"
#21 0.851 Collecting manim==0.19.0 (from -r requirements.txt (line 1))
#21 0.885   Downloading manim-0.19.0-py3-none-any.whl.metadata (11 kB)
#21 1.242 Collecting Pillow>=9.1 (from manim==0.19.0->-r requirements.txt (line 1))
#21 1.250   Downloading pillow-12.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (8.8 kB)
#21 1.257 Requirement already satisfied: Pygments>=2.0.0 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from manim==0.19.0->-r requirements.txt (line 1)) (2.19.2)
#21 1.336 Collecting av<14.0.0,>=9.0.0 (from manim==0.19.0->-r requirements.txt (line 1))
#21 1.362   Downloading av-13.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.4 kB)
#21 1.364 Requirement already satisfied: beautifulsoup4>=4.12 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from manim==0.19.0->-r requirements.txt (line 1)) (4.13.4)
#21 1.384 Collecting click>=8.0 (from manim==0.19.0->-r requirements.txt (line 1))
#21 1.392   Downloading click-8.3.0-py3-none-any.whl.metadata (2.6 kB)
#21 1.418 Collecting cloup>=2.0.0 (from manim==0.19.0->-r requirements.txt (line 1))
#21 1.427   Downloading cloup-3.0.8-py2.py3-none-any.whl.metadata (6.4 kB)
#21 1.430 Requirement already satisfied: decorator>=4.3.2 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from manim==0.19.0->-r requirements.txt (line 1)) (5.2.1)
#21 1.446 Collecting isosurfaces>=0.1.0 (from manim==0.19.0->-r requirements.txt (line 1))
#21 1.457   Downloading isosurfaces-0.1.2-py3-none-any.whl.metadata (3.3 kB)
#21 1.505 Collecting manimpango<1.0.0,>=0.5.0 (from manim==0.19.0->-r requirements.txt (line 1))
#21 1.517   Downloading manimpango-0.6.0.tar.gz (4.1 MB)
#21 1.604      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 MB 52.9 MB/s  0:00:00
#21 1.783   Installing build dependencies: started
#21 4.018   Installing build dependencies: finished with status 'done'
#21 4.019   Getting requirements to build wheel: started
#21 4.658   Getting requirements to build wheel: finished with status 'error'
#21 4.663   error: subprocess-exited-with-error
#21 4.663   
#21 4.663   × Getting requirements to build wheel did not run successfully.
#21 4.663   │ exit code: 1
#21 4.663   ╰─> [28 lines of output]
#21 4.663       Package pangocairo was not found in the pkg-config search path.
#21 4.663       Perhaps you should add the directory containing `pangocairo.pc'
#21 4.663       to the PKG_CONFIG_PATH environment variable
#21 4.663       No package 'pangocairo' found
#21 4.663       Traceback (most recent call last):
#21 4.663         File "<string>", line 137, in check_min_version
#21 4.663         File "/srv/conda/envs/notebook/lib/python3.10/subprocess.py", line 369, in check_call
#21 4.663           raise CalledProcessError(retcode, cmd)
#21 4.663       subprocess.CalledProcessError: Command '['pkg-config', '--print-errors', '--atleast-version', '1.30.0', 'pangocairo']' returned non-zero exit status 1.
#21 4.663       
#21 4.663       During handling of the above exception, another exception occurred:
#21 4.663       
#21 4.663       Traceback (most recent call last):
#21 4.663         File "/srv/conda/envs/notebook/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
#21 4.663           main()
#21 4.663         File "/srv/conda/envs/notebook/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
#21 4.663           json_out["return_val"] = hook(**hook_input["kwargs"])
#21 4.663         File "/srv/conda/envs/notebook/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
#21 4.663           return hook(config_settings)
#21 4.663         File "/tmp/pip-build-env-t08mp1yl/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel
#21 4.663           return self._get_build_requires(config_settings, requirements=[])
#21 4.663         File "/tmp/pip-build-env-t08mp1yl/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
#21 4.663           self.run_setup()
#21 4.663         File "/tmp/pip-build-env-t08mp1yl/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 317, in run_setup
#21 4.663           exec(code, locals())
#21 4.663         File "<string>", line 204, in <module>
#21 4.663         File "<string>", line 140, in check_min_version
#21 4.663       __main__.RequiredDependencyException: pangocairo >= 1.30.0 is required
#21 4.663       [end of output]
#21 4.663   
#21 4.663   note: This error originates from a subprocess, and is likely not a problem with pip.
#21 4.739 error: subprocess-exited-with-error
#21 4.739 
#21 4.739 × Getting requirements to build wheel did not run successfully.
#21 4.739 │ exit code: 1
#21 4.739 ╰─> See above for output.
#21 4.739 
#21 4.739 note: This error originates from a subprocess, and is likely not a problem with pip.
#21 ERROR: process "/bin/sh -c ${KERNEL_PYTHON_PREFIX}/bin/pip install --no-cache-dir -r \"requirements.txt\"" did not complete successfully: exit code: 1

The relevant line is

Package pangocairo was not found in the pkg-config search path.

This indicates a missing dependency.

For comparison, the developers of manin has GitHub - ManimCommunity/jupyter_examples: This repo contains example notebooks which can be launched via binder that is mybinder.org ready but uses it’s a Dockerfile, see jupyter_examples/Dockerfile at 477321861cbe2ebb526304a3e6cbd0ae1ba181b9 · ManimCommunity/jupyter_examples · GitHub, that imports another Dockerfile that I believe to be https://github.com/ManimCommunity/manim/blob/855ea863b690929cd605cfcb9c86a7b3ac6bbcab/docker/Dockerfile.

The only want to use manin will be using Dockerfile as the configuration file.

Thank you very much guys!
My problem is solved. Actually I tried to use a dockerfile before but looking at the example I saw what I did wrong. Now everythin works as needed.
Thanks a lot!

1 Like

For a deployment on binder, the Dockerfile route is going to be much more finicky than the relatively-well-understood environment.yml: chasing down the correct .deb names to get the correct build environment/compiler for a locally-built wheel is a mug’s game.

1 Like

For the record, this simple environment.yml works fine in my fork:

channels:
  - conda-forge
dependencies:
- manim
- pip
- pip:
    - rich

(Ideally, because it can, rich would be directly under conda dependencies; it is under pip only as a placeholder here in this simple example.)

Test it with this launch link.

1 Like

hopefully not too off-topic: what was the issue with rich that required ejecting to pip?

No reason at all. It could be under conda. I just wanted something under there. I should have commented that there.

1 Like