question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support importing in pyodide

See original GitHub issue

Problem

I am a contributor to and user of HoloViz Panel. Panel works with Ipywidgets. Panel can now convert panel apps to webassembly.

BUT it seems I cannot include ipywidgets in those converted apps.

For example if I open the pyodide console and try to

import micropip
micropip.install("ipywidgets")

it fails

....
    raise ValueError(
ValueError: Can't find a pure Python 3 wheel for 'tornado>=6.1'.
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.

image

Proposed Solution

Support importing ipywidgets in pyodide.

Additional context

In the end I would like to be able to panel convert apps like

"""
The purpose of this app is to demonstrate that Panel works with the tools you know and love
❤️, including ipysheet.
"""
import ipysheet
import panel as pn

from awesome_panel import config

config.extension("ipywidgets", url="lib_ipysheet")

ACCENT = config.ACCENT


def get_component(accent_base_color=ACCENT):
    """Returns an ipysheet app"""
    slider = pn.widgets.FloatSlider(value=10, start=0, end=100)
    sheet = ipysheet.sheet()

    ipysheet.cell(1, 1, "Input")
    cell3 = ipysheet.cell(1, 2, 42.0)
    ipysheet.cell(2, 1, "Output")
    cell_sum = ipysheet.cell(2, 2, 52.0, read_only=True, background_color=accent_base_color)

    @pn.depends(slider, cell3, watch=True)
    def calculate(value1, value2):
        cell_sum.value = value1 + value2

    return pn.Column(slider, sheet)


component = get_component()
pn.panel(component, height=700, sizing_mode="stretch_both").servable()

and provide a Basic Ipywidgets App example at https://www.awesome-panel.org/sharing

Originally opened here https://github.com/QuantStack/ipysheet/issues/236.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
martinRenoucommented, Oct 31, 2022

Sorry I read the thread too fast.

So yeah as other said removing the ipykernel dependency or providing a shim for it would be what you need.

1reaction
maartenbreddelscommented, Oct 28, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading packages — Version 0.21.3 - Pyodide
loadPackagesFromImports Pyodide will automatically download all packages that the code snippet imports. This is particularly useful for making a repl since ...
Read more >
How do I import modules in a project using pyodide without ...
runPythonAsync function that will automatically download all packages that the code snippet imports. Here is the minimal example for pyodide.
Read more >
Support importing pyodide as ESM module #2217 - GitHub
Feature This is to propose supporting loading pyodide.js as ESM module. Majority of modern browsers support ESM modules via script: can i ...
Read more >
Pyodide - Read the Docs
After importing Pyodide, only packages from the standard library are ... Pyodide works in any modern web browser with WebAssembly support.
Read more >
Running Panel in the Browser with WASM - GitHub Pages
Panel can be run directly in Pyodide and has special support for rendering ... and packages (relative imports of other scripts or modules...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found