quarto-ext / shinylive

Quarto extension to embed Shinylive for Python applications
https://quarto-ext.github.io/shinylive/
MIT License
151 stars 8 forks source link

import other pyodide packages #57

Open fredguth opened 4 months ago

fredguth commented 4 months ago

I have a shiny app that is able to query a duckdb file and present it in itables (https://github.com/fredguth/shinyduck/blob/main/express-itables-mwe.py)

Now, I am trying to replicate this minimum example to Quarto with {shinylive-python}.

But I am not able to add the package:

Traceback (most recent call last):
  File "<exec>", line 386, in _start_app
  File "/lib/python312.zip/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/pyodide/app_b73jnt6n8j40zt169sfo/app.py", line 10, in <module>
    import duckdb
ModuleNotFoundError: No module named 'duckdb'

There is a pyodide wheel that I was able to use in the shinelive editor online: https://duckdb.github.io/duckdb-pyodide/wheels/duckdb-1.0.0-cp312-cp312-pyodide_2024_0_wasm32.whl

But I was not able to use it with Quarto.

wch commented 4 months ago

Are you using the latest version of the Python shinylive package? It is currently at version 0.5.0. https://pypi.org/project/shinylive/

fredguth commented 4 months ago
❯ poetry run shinylive --version
0.5.0

The same code as a app.py file (outside Quarto) works with shiny run app.py

fredguth commented 3 months ago

Any news on this?

I created another repo where the problem can be seen (https://github.com/fredguth/ducktales) When I quarto preview example.qmd there is an error.

But I then created a shiny folder and run shiny from there shiny run shiny/app.py it works.