Streamlit Desktop App with Electron

Hello everyone,

I am new to streamlit + stlite + electron workflow and was encountering this error while running npm run dump streamlit_app. Any help is greatly appreciated!

PythonError: Traceback (most recent call last):
  File "/lib/python311.zip/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1209, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1181, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1145, in _find_and_load_unlocked
ModuleNotFoundError: The module 'micropip' is included in the Pyodide distribution, but it is not installed.
You can install it by calling:
  await micropip.install("micropip") in Python, or
  await pyodide.loadPackage("micropip") in JavaScript
See https://pyodide.org/en/stable/usage/loading-packages.html for more details.

    at new_error (C:\Users\user\streamlit-desktop\node_modules\pyodide\pyodide.asm.js:9:12519)
    at wasm://wasm/02250ad6:wasm-function[295]:0x158827
    at wasm://wasm/02250ad6:wasm-function[296]:0x15892c
    at Module._pythonexc2js (C:\Users\user\streamlit-desktop\node_modules\pyodide\pyodide.asm.js:9:640895)
    at Module.callPyObjectKwargs (C:\Users\user\streamlit-desktop\node_modules\pyodide\pyodide.asm.js:9:81856)
    at Module.callPyObject (C:\Users\user\streamlit-desktop\node_modules\pyodide\pyodide.asm.js:9:82066)
    at Qe.apply (C:\Users\user\streamlit-desktop\node_modules\pyodide\pyodide.asm.js:9:97147)
    at Object.apply (C:\Users\user\streamlit-desktop\node_modules\pyodide\pyodide.asm.js:9:95381)
    at Object.pyimport (C:\Users\user\streamlit-desktop\node_modules\pyodide\pyodide.asm.js:9:119720)
    at z (C:\Users\user\streamlit-desktop\node_modules\@stlite\desktop\bin\dump_artifacts.js:3:3130)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async C:\Users\user\streamlit-desktop\node_modules\@stlite\desktop\bin\dump_artifacts.js:17:2196 {
  type: 'ModuleNotFoundError',
  __error_address: 9780880
}

Node.js v18.12.1
1 Like

I also received this error. Do you manage to solve this?

I am just going to copy paste my answer from github.

This error occurs when you are on a restricted network for instance, on corporate network. This means that cdn.delivry.js is blocked on the network which is preventing the download of micropip and other whl files. To get around it, manually download the pyodide latest release from here (Release 0.25.0 · pyodide/pyodide · GitHub) and extract it in the pyodide folder of node_modules.

This would get rid of the error but it might create a new one because we are still on restricted network and there are a lot of dependencies being accessed from various different urls.

To know what is actually getting restricted, use stlite mountable and inspect network in browser. This just tells where the issue lies, doesn’t fix it. The only way to fix it to get it unblocked or switching to a unrestricted network. I tried hosting the whl pyodide and stlite files for stlite-mountable on localhost which worked and loaded micropip but then it got blocked at tenacity-8.2.3-py3-none-any.whl and six other whl required from https://files.pythonhosted.org. I am not sure how to redirect those requests to my local server.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.