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

thebe-lite demo not working due to missing ipywidgets wheel #689

Closed
stevejpurves opened this issue Sep 28, 2023 · 4 comments
Closed

thebe-lite demo not working due to missing ipywidgets wheel #689

stevejpurves opened this issue Sep 28, 2023 · 4 comments
Assignees
Labels
bug thebe-lite Applies to thebe-lite and all things thebe-WASM

Comments

@stevejpurves
Copy link
Member

Describe the bug

context
When I do visit the online demo https://executablebooks.github.io/thebe/ and run it

expectation
I expected the code cell to produce an interactive output

bug
But instead an error is reported

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 await __import__("piplite").install(**{'requirements': ['ipywidgets']})
      3 import numpy as np
      4 import matplotlib.pyplot as plt

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:457, in Transaction.add_requirement_inner(self, req)
    452 if self.check_version_satisfied(req):
    453     # Maybe while we were downloading pypi_json some other branch
    454     # installed the wheel?
    455     return
--> 457 await self.add_wheel(wheel, req.extras)

File /lib/python3.11/site-packages/micropip/_micropip.py:472, in Transaction.add_wheel(self, wheel, extras)
    470 await wheel.download(self.fetch_kwargs)
    471 if self.deps:
--> 472     await self.gather_requirements(wheel.requires(extras))
    474 self.wheels.append(wheel)

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:346, in Transaction.add_requirement(self, req)
    344 async def add_requirement(self, req: str | Requirement) -> None:
    345     if isinstance(req, Requirement):
--> 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))

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 'widgetsnbextension~=4.0.9'.
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.

problem
This is a problem for people visiting the demo or trying to use ipywidgets in thebe-lite

Reproduce the bug

  1. visit the online demo https://executablebooks.github.io/thebe/
  2. activate
  3. run all

List your environment

No response

@stevejpurves stevejpurves added bug thebe-lite Applies to thebe-lite and all things thebe-WASM labels Sep 28, 2023
@stevejpurves stevejpurves self-assigned this Sep 28, 2023
@stevejpurves
Copy link
Member Author

the same code is working in the latest juptyerlite demo https://jupyter.org/try-jupyter/lab/index.html

perhaps we need an upgrade to get some changes / improvements in the package management / micropip usage?

@agoose77
Copy link

agoose77 commented Oct 2, 2023

@stevejpurves it's not working for me in try-jupyter either :). Weird, I cleared the cache and I think it works. Perhaps we're both seeing old-cache problems.

@stevejpurves
Copy link
Member Author

stevejpurves commented Oct 4, 2023

@agoose77 just to clarify - it's working for me in try-jupyter and not in the thebe demo, even after clearing cache & unregistering service worker.

Were you saying after clearing cache it works in both places?

@jtpio
Copy link
Contributor

jtpio commented Oct 4, 2023

The Pyodide kernel currently includes a shim for widgetsnbextension with a specific version. So when there is a new version of widgetsnbextension the Pyodide kernel has to be updated as well, which is quite annoying. For reference this is not an issue with the xeus python kernel.

This was fixed in jupyterlite-pyodide-kernel: jupyterlite/pyodide-kernel#62

An other relevant issue for the same problem: jupyter-widgets/ipywidgets#3819

So updating to the latest jupyterlite-pyodide-kernel and ipywidgets should help fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug thebe-lite Applies to thebe-lite and all things thebe-WASM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants