Shinylive Python Installation & Deployment
Installation from PyPI
Install the latest stable version of Shinylive Python:
pip install shinylive
Installation from GitHub
To install the development version:
pip install git+https://github.com/posit-dev/py-shinylive.git
Exporting and Deploying Your App
Export your Shiny app as a static webpage:
shinylive export my_app_dir my_site_dir
Preview locally:
python3 -m http.server --directory my_site_dir 8000
Access at: http://localhost:8000
Detailed Tutorial on Installation & Deployment
Creating Basic Shinylive Python Apps
Minimal Shinylive App Example
from shiny import App, ui, render
= ui.page_fluid(
app_ui "n", "N", 0, 100, 40),
ui.input_slider("result")
ui.output_text_verbatim(
)
def server(input, output, session):
@output
@render.text
def result():
return f"You selected {input.n()}"
= App(app_ui, server) app
Export and Preview
shinylive export my_app my_site
python3 -m http.server --directory my_site
Quarto Integration Tips for Python Apps
Installing the Shinylive Quarto Extension
From terminal within your Quarto project:
quarto add quarto-ext/shinylive
YAML Setup for Shinylive
In your .qmd
document:
---
format: html
filters:
- shinylive
---
Embedding Apps in Quarto
```{shinylive-python}
#| standalone: true
from shiny import App, render, ui
app_ui = ui.page_fluid(
ui.input_slider("n", "Number", 0, 10, 5),
ui.output_text("out")
)
def server(input, output, session):
@output
@render.text
def out():
return f"Square of {input.n()} is {input.n()**2}"
app = App(app_ui, server)
```
Detailed Quarto Integration Guide
#| '!! shinylive warning !!': |
#| shinylive does not work in self-contained HTML documents.
#| Please set `embed-resources: false` in your metadata.
#| standalone: true
#| viewerHeight: 300
from shiny import App, render, ui
app_ui = ui.page_fluid(
ui.input_slider("n", "Number", 0, 10, 5),
ui.output_text("out")
)
def server(input, output, session):
@output
@render.text
def out():
return f"Square of {input.n()} is {input.n()**2}"
app = App(app_ui, server)
Troubleshooting Common Issues
App Does Not Load
- Ensure the Shinylive extension and dependencies are installed correctly.
- Verify the export path and static assets.
Missing Python Package
If a package is missing:
import micropip
await micropip.install("pandas")
Browser Compatibility
- Use a modern browser like Chrome, Firefox, or Edge.
- Check browser console logs (
F12
) for detailed error messages.
Further Reading
Explore More Articles
Here are more articles from the same category to help you dive deeper into the topic.
Reuse
Citation
@online{kassambara2025,
author = {Kassambara, Alboukadel},
title = {Shinylive {Essentials} for {Python} {Cheatsheet}},
date = {2025-03-22},
url = {https://www.datanovia.com/learn/interactive/cheatsheets/shinylive-essentials-python.html},
langid = {en}
}