Skip to main content

Using Packages

Packages can be installed using the following Packages object and can be imported either globally through the provider, or per instance. For props, see the API reference docs.

Example importing packages globally:

import { PythonProvider } from 'react-py'

function App() {
const packages = {
official: ['asciitree'],
micropip: ['python-cowsay'],
}

return (
<PythonProvider packages={packages}>
<Codeblock />
</PythonProvider>
)
}

...

Example importing packages per instance:

import { usePython } from 'react-py'

const packages = {
official: ['asciitree'],
micropip: ['python-cowsay'],
}

function Codeblock() {
const { runPython, ... } = usePython(packages)

...
}

Python standard library

The Python standard library is available without needing to install any packages, view the full list here.

Example using uuid.

Loading...

Pyodide official packages

There is a list of official packages included with Pyodide, view the full list here.

Example using asciitree.

Loading...

Installing packages with micropip

Micropip can be used to install pure Python packages with wheels available on PyPI or from other URLs.

Example using python-cowsay.

Loading...