Declare pinned app requirements or install a package from Python inside the Gradio Lite browser runtime.
The browser runtime includes Python, Gradio, and packages available through its Pyodide distribution. Declare an app requirement when your app needs another installable Python package.
A package is an installable distribution such as transformers-js-py. A module is the name used in Python import statements, such as transformers_js_py. Their names can differ.
Choose an installation path
Path
Use it when
Scope
gradio.requirements
The document always needs the package
Every embedded app in the document
micropip.install()
The app decides what to install at runtime
The worker that executes that source
Prefer document requirements for a predictable published app. Pin exact versions so a new package release cannot change app startup without a document change.
Declare document requirements
Add the requirement to the document’s YAML front matter:
plotly==5.24.1
import micropip
await micropip.install("faker==37.8.0")
import gradio as gr
import pandas as pd
from faker import Faker
fake = Faker()
generators = {
"Name": fake.name,
"Address": fake.address,
"Email": fake.email,
"Phone": fake.phone_number,
"Job": fake.job,
}
def generate_data(data_type, count):
rows = [
{"#": index + 1, "Data": generators[data_type]()}
for index in range(count)
]
return pd.DataFrame(rows)
demo = gr.Interface(
fn=generate_data,
inputs=[
gr.Dropdown(list(generators), value="Name"),
gr.Slider(1, 10, value=3, step=1),
],
outputs=gr.Dataframe(wrap=True),
)
demo.launch()
Choose a data type and count, then submit. The app installs Faker and returns generated rows.
Check compatibility
Pyodide can install pure Python wheels and packages built for its WebAssembly environment. A package that requires an unavailable native library will fail to install. Large packages and model downloads also increase first-start time.
Inspect the visible Python error and browser console.
Confirm that the package and wheel origins are reachable and allow cross-origin requests.
App requirements are separate from the extension’s runtime compatibility pins. The latter boot the frozen Gradio Lite environment and are not an author configuration surface.
See Runtime and Trust for the complete package and network boundary.