CautionAlert
This book walks through how to build Shiny for Python applications inside Python packages. It is a Python companion to Shiny App-Packages, which covers the same workflow for R.
Getting your Shiny for Python app into a Python package
Shiny for Python combines the power of Python’s data science and machine learning capabilities with the interactivity of a web-based application.
Python packages are collections of pre-built, self-contained code, data, and documentation designed to perform operations or accomplish tasks beyond the capabilities of the Python language.
The book follows a single example application from a bare script through a fully packaged, tested, and deployed Shiny app.
Each part builds on the last:
| Part | Topic |
|---|---|
| Introduction | Shiny for Python basics and Python package fundamentals |
| App-Packages | Documentation, dependencies, data, and static resources |
| Debugging | Using the Python debugger and logging inside Shiny apps |
| Testing | pytest setup, fixtures, module tests, and end-to-end tests |
| Deployment | Posit Connect, Docker, GitHub Actions, and PyPI |
| Project Patterns | Flat, src/, and monorepo layouts |
| Tools | AI-assisted development and code quality tooling |
| Special Topics | Dynamic UI, app data patterns, Python classes, and reactive design |
This book isn’t a replacement for the official Shiny for Python documentation. I highly suggest bookmarking this as a resources for up-to-date news and features.
Readers should be comfortable with basic Python and have some exposure to Shiny for Python. No prior experience with Python packaging is assumed.
All Shiny code uses Shiny Core.1
Code that is meant to be typed in a terminal looks like this:
$ pip install shinyor2
>>> import numpy as npCode that belongs in a Python file looks like this:
from shiny import App, ui, render