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

Using Panel in Pyodide outdated #5307

Closed
MarcSkovMadsen opened this issue Jul 23, 2023 · 5 comments · Fixed by #5308
Closed

Using Panel in Pyodide outdated #5307

MarcSkovMadsen opened this issue Jul 23, 2023 · 5 comments · Fixed by #5308
Labels
good first issue Good for newcomers type: bug Something isn't correct or isn't working
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

The description in https://panel.holoviz.org/how_to/wasm/standalone.html uses outdated versions of Panel.

image

@MarcSkovMadsen MarcSkovMadsen added the type: bug Something isn't correct or isn't working label Jul 23, 2023
@MarcSkovMadsen MarcSkovMadsen added this to the next milestone Jul 23, 2023
@MarcSkovMadsen MarcSkovMadsen added the good first issue Good for newcomers label Jul 23, 2023
@MarcSkovMadsen
Copy link
Collaborator Author

Maybe we should have a latest release @philippjfr we can point to in the documentation such that it will always be working?

@Kislovskiy
Copy link
Contributor

I'm trying to fix the issue. With the following html

<html>
  <head>
    <script src="https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js"></script>

    <script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-3.2.0.js"></script>
    <script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.2.0.min.js"></script>
    <script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.2.0.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@holoviz/panel@1.2.0/dist/panel.min.js"></script>

  </head>
  <body>
    <div id="simple_app"></div>
    <script type="text/javascript">
      async function main(){
        let pyodide = await loadPyodide();
        await pyodide.loadPackage("micropip");
        const micropip = pyodide.pyimport("micropip");
        await micropip.install('panel')
        pyodide.runPython(`
          import panel as pn

          pn.extension(sizing_mode="stretch_width")

          slider = pn.widgets.FloatSlider(start=0, end=10, name='Amplitude')

          def callback(new):
              return f'Amplitude is: {new}'

          pn.Row(slider, pn.bind(callback, slider)).servable(target='simple_app');
	    `);
      }
      main();
    </script>
  </body>
</html>

After starting the web server with python3 -m http.server. I'm getting:

Uncaught (in promise) PythonError: Traceback (most recent call last):
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 576, in install
    await transaction.gather_requirements(requirements)
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 342, in gather_requirements
    await gather(*requirement_promises)
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 349, in add_requirement
    return await self.add_requirement_inner(Requirement(req))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 457, in add_requirement_inner
    await self.add_wheel(wheel, req.extras)
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 472, in add_wheel
    await self.gather_requirements(wheel.requires(extras))
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 342, in gather_requirements
    await gather(*requirement_promises)
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 346, in add_requirement
    return await self.add_requirement_inner(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 457, in add_requirement_inner
    await self.add_wheel(wheel, req.extras)
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 472, in add_wheel
    await self.gather_requirements(wheel.requires(extras))
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 342, in gather_requirements
    await gather(*requirement_promises)
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 346, in add_requirement
    return await self.add_requirement_inner(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 444, in add_requirement_inner
    wheel = find_wheel(metadata, req)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 312, in find_wheel
    raise ValueError(
ValueError: Can't find a pure Python 3 wheel for 'tornado>=5.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.
    PythonError https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    new_error https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    _PyCFunctionWithKeywords_TrampolineCall https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    callPyObjectKwargs https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    callPyObject https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    wrapper https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    setTimeout handler*hiwire_call_bound https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    _PyCFunctionWithKeywords_TrampolineCall https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    callPyObjectKwargs https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    callPyObject https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    wrapper https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    setTimeout handler*hiwire_call_bound https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9
    _PyCFunctionWithKeywords_TrampolineCall https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.asm.js:9

@MarcSkovMadsen
Copy link
Collaborator Author

Let me have a look

@MarcSkovMadsen
Copy link
Collaborator Author

I can see this one works

<html>
  <head>
    <script src="https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js"></script>

    <script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-3.2.0.js"></script>
    <script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.2.0.min.js"></script>
    <script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.2.0.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@holoviz/panel@1.2.0/dist/panel.min.js"></script>

  </head>
  <body>
    <div id="simple_app"></div>
    <script type="text/javascript">
      async function main(){
        let pyodide = await loadPyodide();
        await pyodide.loadPackage("micropip");
        const micropip = pyodide.pyimport("micropip");
        await micropip.install([
          "https://cdn.holoviz.org/panel/1.2.0/dist/wheels/bokeh-3.2.0-py3-none-any.whl",
          "https://cdn.holoviz.org/panel/1.2.0/dist/wheels/panel-1.2.0-py3-none-any.whl"]
        )
        pyodide.runPython(`
          import panel as pn

          pn.extension(sizing_mode="stretch_width")

          slider = pn.widgets.FloatSlider(start=0, end=10, name='Amplitude')

          def callback(new):
              return f'Amplitude is: {new}'

          pn.Row(slider, pn.bind(callback, slider)).servable(target='simple_app');
	    `);
      }
      main();
    </script>
  </body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants