-
|
The following page: <!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/pyodide/v0.19.1/full/pyodide.js"></script>
</head>
<body>
<script type="text/javascript">
async function main(){
let pyodide = await loadPyodide({
indexURL : "https://cdn.jsdelivr.net/pyodide/v0.19.1/full/"
});
console.log(pyodide.runPython(`
import micropip
`));
}
main();
</script>
</body>
</html>This produces a hard-to-decipher error if this is runPythonAsync, FYI (image below). Using the sync version as above produces the proper ModuleNotFoundError, but why is that not found? Other modules work fine, just not micropip? Is there something I'm missing? FYI, just serving this locally. FYI, the FAQ docs here seem to be incorrect: pyodide.runPython(`
from pyodide.http import pyfetch
response = await pyfetch("https://some_url/...")
if response.status == 200:
with open("<output_file>", "wb") as f:
f.write(await response.bytes())
`)I think that's |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 16 replies
-
|
You have to run PythonError: Traceback (most recent call last):
File "/lib/python3.9/asyncio/futures.py", line 201, in result
raise self._exception
File "/lib/python3.9/asyncio/tasks.py", line 256, in __step
result = coro.send(None)
File "/lib/python3.9/site-packages/_pyodide/_base.py", line 494, in eval_code_async
await CodeRunner(
File "/lib/python3.9/site-packages/_pyodide/_base.py", line 345, in run_async
coroutine = eval(self.code, globals, locals)
File "<exec>", line 2, in <module>
ModuleNotFoundError: No module named 'micropipThe top two frames in |
Beta Was this translation helpful? Give feedback.
-
It's a quite strange traceback, in the JS console (with the REPL 0.20.0a1) it seems to work as expected (i.e. raise the expected error), >>> pyodide.runPython('import micropip')
Python exception:
Traceback (most recent call last):
File "/lib/python3.9/site-packages/_pyodide/_base.py", line 415, in eval_code
CodeRunner(
File "/lib/python3.9/site-packages/_pyodide/_base.py", line 296, in run
coroutine = eval(self.code, globals, locals)
File "<exec>", line 1, in <module>
ModuleNotFoundError: No module named 'micropip' |
Beta Was this translation helpful? Give feedback.

You have to run
await pyodide.loadPackage('micropip');before importingmicropip. Loading micropip is around ~500kb of data transfer and many applications won't need it. Thanks for pointing out the FAQ error. WithrunPythonAsyncI get the following stack trace: