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

Make pygraphviz work in Pyodide and Jupyterlite #453

Open
MarcSkovMadsen opened this issue Apr 14, 2023 · 1 comment
Open

Make pygraphviz work in Pyodide and Jupyterlite #453

MarcSkovMadsen opened this issue Apr 14, 2023 · 1 comment

Comments

@MarcSkovMadsen
Copy link

MarcSkovMadsen commented Apr 14, 2023

Intro

I'm a user of and contributor to Panel and the HoloViz ecosystem. With Panel you can make interactive components for Jupyter and data apps that runs in your browser. Panel can also run in the browser only via Pyodide or Pyscript. It can also run in a custom version of Jupyterlite called Panelite.

I'm currently testing some of the notebooks in Panelite. One shows how to use Panel with networkx. Unfortunately the dependency pygraphviz cannot be imported in Jupyterlite.

So my wish is that pygraphviz would work in Pyodide and Jupyterlite. I believe other users would too as Pyodide, Pyscript and Jupyterlite is the future for learning and light data analysis work.

Reproduce issue

import piplite
await piplite.install(['pygraphviz'])

and see the error

image

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 2
      1 import piplite
----> 2 await piplite.install(['pygraphviz'])

File /lib/python3.11/site-packages/piplite/piplite.py:103, in _install(requirements, keep_going, deps, credentials, pre)
    101 """Invoke micropip.install with a patch to get data from local indexes"""
    102 with patch("micropip._micropip._get_pypi_json", _get_pypi_json):
--> 103     return await _micropip.install(
    104         requirements=requirements,
    105         keep_going=keep_going,
    106         deps=deps,
    107         credentials=credentials,
    108         pre=pre,
    109     )

File /lib/python3.11/site-packages/micropip/_micropip.py:576, in install(requirements, keep_going, deps, credentials, pre)
    566 wheel_base = Path(getsitepackages()[0])
    568 transaction = Transaction(
    569     ctx=ctx,
    570     ctx_extras=[],
   (...)
    574     fetch_kwargs=fetch_kwargs,
    575 )
--> 576 await transaction.gather_requirements(requirements)
    578 if transaction.failed:
    579     failed_requirements = ", ".join([f"'{req}'" for req in transaction.failed])

File /lib/python3.11/site-packages/micropip/_micropip.py:342, in Transaction.gather_requirements(self, requirements)
    339 for requirement in requirements:
    340     requirement_promises.append(self.add_requirement(requirement))
--> 342 await gather(*requirement_promises)

File /lib/python3.11/site-packages/micropip/_micropip.py:349, in Transaction.add_requirement(self, req)
    346     return await self.add_requirement_inner(req)
    348 if not urlparse(req).path.endswith(".whl"):
--> 349     return await self.add_requirement_inner(Requirement(req))
    351 # custom download location
    352 wheel = WheelInfo.from_url(req)

File /lib/python3.11/site-packages/micropip/_micropip.py:444, in Transaction.add_requirement_inner(self, req)
    441 metadata = await _get_pypi_json(req.name, self.fetch_kwargs)
    443 try:
--> 444     wheel = find_wheel(metadata, req)
    445 except ValueError:
    446     self.failed.append(req)

File /lib/python3.11/site-packages/micropip/_micropip.py:312, in find_wheel(metadata, req)
    309     if best_wheel is not None:
    310         return wheel
--> 312 raise ValueError(
    313     f"Can't find a pure Python 3 wheel for '{req}'.\n"
    314     f"See: {FAQ_URLS['cant_find_wheel']}\n"
    315     "You can use `micropip.install(..., keep_going=True)`"
    316     "to get a list of all packages with missing wheels."
    317 )

ValueError: Can't find a pure Python 3 wheel for 'pygraphviz'.
See: https://pyodide.org/en/stable/usage/faq.html#micropip-can-t-find-a-pure-python-wheel
You can use `micropip.install(..., keep_going=True)`to get a list of all packages with missing wheels.
@rossbar
Copy link
Contributor

rossbar commented Apr 18, 2023

From the traceback, this line seems the most relevant:

ValueError: Can't find a pure Python 3 wheel for 'pygraphviz'.

which is expected, as there are currently no wheels for pygraphviz. This is of course the biggest pain point for basically all users (see the rest of the issue tracker) and is something that we'd very much like to resolve, but it is quite complicated due to the dependency on graphviz. See #167 for the most in-depth context and #421 for a recent-ish attempt at wrapping.

Unfortunately, even if we were able to get wheels working, they could not be pure Python as pygraphviz wraps the graphviz project written in C. However that's a future bridge to be crossed - the first step would be getting pygraphviz wheels out.

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

No branches or pull requests

2 participants