pyodide icon indicating copy to clipboard operation
pyodide copied to clipboard

indexURL in loadPyodide

Open nubol23 opened this issue 1 year ago • 1 comments

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 avatar Oct 06 '24 15:10 nubol23

@nubol23, thanks for letting us know! Updates to the documentation are welcomed – would you like to add this?

agriyakhetarpal avatar Oct 06 '24 17:10 agriyakhetarpal

why use indexURL ? . May be using load from local folder?

thangtuts avatar Oct 22 '24 08:10 thangtuts

This can be closed now

ShauryaDusht avatar May 22 '25 11:05 ShauryaDusht