pyodide
pyodide copied to clipboard
indexURL in loadPyodide
In the docs about using bundlers like vite here: https://pyodide.org/en/stable/usage/working-with-bundlers.html
The provided example
import { loadPyodide } from "pyodide";
async function hello_python() {
let pyodide = await loadPyodide();
return pyodide.runPythonAsync("1+1");
}
hello_python().then((result) => {
console.log("Python says that 1+1 =", result);
});
Works well for vanilla python and std libs, but when we need to import libraries like numpy it fails.
Had to find this blog to understand that we need to specify indexURL like:
pyodide = await loadPyodide({
indexURL: "https://cdn.jsdelivr.net/pyodide/v0.26.2/full/",
});
for it to work.
I think the docs should specify this case in the example.
@nubol23, thanks for letting us know! Updates to the documentation are welcomed – would you like to add this?
why use indexURL ? . May be using load from local folder?
This can be closed now