Skip to content
A clean 2D 8-bit style graphic featuring a beige python snake curled around flat geometric icons of a browser window and a folder, with circuit board lines representing WebAssembly and a blue gear indicating Python code execution. The design uses five corporate colors, has no background or text, appears sleek and iconic, and is set at small square dimensions with clear, sharp lines.

Pyodide

Pyodide is a distribution of Python for Node.js (and the browser).

Pyodide is a port of CPython to WebAssembly/Emscripten. Pyodide makes it possible to install and run Python packages in the browser with micropip.

GenAIScript provides a convinience layer to start pyodide python runtimes.

The host.python starts an instance of Pyodide.

const py = await host.python()

Each Pyodide instance has a run method that can be used to run Python code.

const result = await py.run(`print('Hello, World!')`)

You can read and write global variables in the Pyodide environment.

py.globals.set("x", 42)
const x = py.globals.get("x")
await py.run(`print(x)`)

The current workspace file system is mounted on the /workspace directory in the Pyodide environment.

const result = await runtime.run(`
import os
os.listdir('/workspace')
`)
console.log({ result })

This features is powered by Pyodide. For more information, please refer to the Pyodide documentation.