0

Trying to make some math visualizations, and I hear Manim is the go-to for that.

Working in Jupyter. When I run:

from manim import *

I get:

---------------------------------------------------------------------------
ContextualVersionConflict                 Traceback (most recent call last)
Cell In[14], line 1
----> 1 from manim import *

File ~\anaconda3\lib\site-packages\manim\__init__.py:8
      4 from __future__ import annotations
      6 import pkg_resources
----> 8 __version__: str = pkg_resources.get_distribution(__name__).version
     11 import sys
     13 # isort: off
     14 
     15 # Importing the config module should be the first thing we do, since other
     16 # modules depend on the global config dict for initialization.

File ~\anaconda3\lib\site-packages\pkg_resources\__init__.py:478, in get_distribution(dist)
    476     dist = Requirement.parse(dist)
    477 if isinstance(dist, Requirement):
--> 478     dist = get_provider(dist)
    479 if not isinstance(dist, Distribution):
    480     raise TypeError("Expected string, Requirement, or Distribution", dist)

File ~\anaconda3\lib\site-packages\pkg_resources\__init__.py:354, in get_provider(moduleOrReq)
    352 """Return an IResourceProvider for the named module or requirement"""
    353 if isinstance(moduleOrReq, Requirement):
--> 354     return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
    355 try:
    356     module = sys.modules[moduleOrReq]

File ~\anaconda3\lib\site-packages\pkg_resources\__init__.py:909, in WorkingSet.require(self, *requirements)
    900 def require(self, *requirements):
    901     """Ensure that distributions matching `requirements` are activated
    902 
    903     `requirements` must be a string or a (possibly-nested) sequence
   (...)
    907     included, even if they were already activated in this working set.
    908     """
--> 909     needed = self.resolve(parse_requirements(requirements))
    911     for dist in needed:
    912         self.add(dist)

File ~\anaconda3\lib\site-packages\pkg_resources\__init__.py:800, in WorkingSet.resolve(self, requirements, env, installer, replace_conflicting, extras)
    797 if dist not in req:
    798     # Oops, the "best" so far conflicts with a dependency
    799     dependent_req = required_by[req]
--> 800     raise VersionConflict(dist, req).with_context(dependent_req)
    802 # push the new requirements onto the stack
    803 new_requirements = dist.requires(req.extras)[::-1]

ContextualVersionConflict: (Pygments 2.11.2 (c:\users\nsdsm\anaconda3\lib\site-packages), Requirement.parse('pygments<3.0.0,>=2.13.0'), {'rich'})
-----------------------------------------------------------

Tried to fix by reinstalling "pygments" because ChatGPT recommended that as the fix. Didn't fix it.

!pip uninstall pygments -y
!pip install pygments
C.Nivs
  • 12,353
  • 2
  • 19
  • 44
  • Because your error shows conda/anaconda is **your main package manager**, you should always deal with that first and avoid as much as you can mixing and matching conda and pip use. It will make for more robust, stable, and portable environments for you with less hassles like these. Only resort to pip for things that conda doesn't offer. There is a way to use conda to install manim as described [here](https://docs.manim.community/en/stable/installation/conda.html). If you then want to use Jupyter within that conda environment. See [here](https://stackoverflow.com/a/58198701/8508004) for the... – Wayne May 19 '23 at 15:17
  • the best way to do that. Hopefully by using conda to do this you can avoid all that issue and it will just work. However, you seem to be just wanting to try manim at this point, right? Normally, I'd suggest you can get a working temporary Jupyter session with manim working by on a remote machine with limited resources going [here](https://docs.manim.community/en/stable/installation/jupyter.html) and clicking on https://try.manim.community/ towards the top there or just put that 'try' url in your browser. ... – Wayne May 19 '23 at 15:39
  • However, right now the the mybinder service is a little rocky though, see [here](https://blog.jupyter.org/mybinder-org-reducing-capacity-c93ccfc6413f). **Just now** I was able to sort of get manim working on a remote mybinder session by going [here](https://github.com/binder-examples/requirements). And then in the session that came up, I opened a new notebook and ran in the notebook `%conda install -c conda-forge manim`. And then `%conda install -c conda-forge texlive-core`. I restarted the kernel when prompted at the end of those installs. Then I ran ... – Wayne May 19 '23 at 15:42
  • `!curl -OL https://raw.githubusercontent.com/ManimCommunity/jupyter_examples/main/basic_example_scenes.ipynb`. When that notebook showed up in the file navigator pane on the left (you can hit the circular arrow just above the pane to refresh if you rather not wait), I double clicking on it and ran all the first four cells and it worked. [Latex isn't quite working in that session](https://github.com/conda-forge/texlive-core-feedstock/issues/19) so the fifth doesn't work. But it launches more easily then the manim community one. That manim community one does indeed work better. ... – Wayne May 19 '23 at 15:55
  • **Today, I had to use [this url](https://ovh.mybinder.org/v2/gh/ManimCommunity/jupyter_examples/HEAD?filepath=First%20Steps%20with%20Manim.ipynb) to launch the manim community one and even that took a couple tries**. But the first notebook seems to work great and latex works. But the first notebook seems to work great and latex works. You can click the Jupyter logo in the upper left side to get to a page with a file navigator and double-click to open the `basic_example_scenes.ipynb` notebook and those. They are **very impressive!** – Wayne May 19 '23 at 15:55
  • As an aside, for a better experience installing inside notebooks....In modern Jupyter (not Colab), it should be `%pip install ...` as the command for running a pip install inside notebook cells. The exclamation point in conjunction with install commands can cause issues & so the magic `%pip install` and `%conda install` commands were added to insure installation occurs in the environment being used by the kernel underlying the notebook, see [here](https://discourse.jupyter.org/t/why-users-can-install-modules-from-pip-but-not-from-conda/10722/4?u=fomightez) for more about the modern magic ... – Wayne May 19 '23 at 15:55
  • install commands. See [the second paragraph here](https://discourse.jupyter.org/t/location-of-libraries-or-extensions-installed-in-jupyterlab/16303/2?u=fomightez) for more on why to avoid exclamation point with install commands when running inside a cell in modern Jupyter. – Wayne May 19 '23 at 15:55

0 Answers0