Skip to content

got error: await pyodide_js.loadPackage('pandas') #72

@hopezh

Description

@hopezh

I was running the code in a quarto qmd file which is the same as the one shown in the "Module Communication" chapter and section "Passing multiple UI elements to modules".

Image

I got the following error while previewing the qmd file. I do have pandas installed.

Error starting app!
Traceback (most recent call last):
  File "<exec>", line 241, 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 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/pyodide/app_u9zbmwr3kwwv39hgcmeb/app.py", line 3, in <module>
    from .modules import table_cards_server, table_cards_ui
  File "/home/pyodide/app_u9zbmwr3kwwv39hgcmeb/modules.py", line 2
    await pyodide_js.loadPackage('pandas')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'await' outside function

Image

May I ask how to solve this issue? Thanks.

PS: the same code runs correctly as two python files, instead of running as shinylive-python code block in a qmd file. (only need to change from .modules import... to from modules import...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions