Skip to content

Pyodide

These runtime helpers provide a friendly wrapper around the pyodide ecosystem to execute Python code in the browser.

Terminal window
npm i -D @genaiscript/plugin-pyodide

If you are using the plugin in a Node.JS environment, without a .genai... entry file, you will need to initialize the runtime before using the plugin:

import { initialize } from "@genaiscript/runtime";
await initialize();
import { python } from "@genaiscript/plugin-pyodide";
const py = await python();
const result = await py(`
def greet(name):
return f"Hello, {name}!"
greet("World")
`);
console.log(result); // "Hello, World!"