What's Shiny (for Python)?
Shiny was developed in 2012 as an R package and enables data scientists to create interactive web applications and dashboards directly in R. Users can explore, visualize, and analyze data without needing to program themselves. This makes data analysis accessible to a broader group of decision-makers and promotes data-driven decision-making.
In 2022, Posit expanded the Shiny ecosystem with Shiny for Python, allowing applications to also be developed in Python. While the R Shiny community has historically been more academically oriented, the rapidly growing Python community is more focused on business requirements. At eoda, we use Shiny for Python for interactive web applications with complex analyses that support companies in making data-driven decisions.
R Shiny and Shiny for Python follow the same principles in terms of architecture, reactive programming logic, deployment, and scaling. This enables Python developers to create interactive dashboards and web applications directly in Python. The integration of libraries such as NumPy, Polars, PyTorch, or TensorFlow, as well as integration into modern development and CI/CD processes, makes Shiny for Python particularly suitable for production-ready data products and ML-supported applications.
What is Shiny (for Python) suitable for?
For more than 15 years, we have been developing data-driven solutions and dashboards for a wide range of industries. Based on our experience, Shiny is a tool that is best suited for:
- Companies / organizations that not only want to visualize data, but also want to make and execute decisions based on it
- Having different users who need access to this information in their daily work.
- Want to share understandable representations of information with others
Shiny for Python makes particular sense for teams that
- already use established Python-based pipelines for development, testing, and deployment,
- want to create, use, and share fast visualizations and interactive web applications,
- want to continue using the extensive Python ecosystem of libraries and tools for machine learning, data analysis, and visualization.
Comparison of Shiny for Python
Shiny for Python vs Streamlit
Streamlit is an open-source framework for Python that allows interactive web applications for data analysis and machine learning to be created quickly. Streamlit follows a very simple and declarative approach. An application is essentially written like a normal Python script that is completely re-executed with every user interaction. This makes it particularly easy to get started and is mainly aimed at data scientists who want to build prototypes or simple data apps without extensive web development knowledge.
Shiny for Python, however, uses reactive logic in which an input triggers a direct recalculation/change only in the corresponding components that the input refers to. Like R Shiny, Shiny for Python separates the user interface and server, which facilitates maintenance and scalability even for complex applications. For this reason, we choose Shiny (for Python) for applications that will evolve over time.
| Shiny for Python | Streamlit | |
|---|---|---|
| Reactivity | Automatic | The entire script is re-executed upon interaction |
| Learning curve | Somewhat more structured, conceptually stronger | Very low barrier to entry |
| Use Cases | Structured business or analytics apps | Rapid prototypes, data demos, ML showcases |
| Scalability | Highly scalable through modular architecture and reactive model | Limited scalability for very large or complex applications |
| Target audience | Data scientists with a need for scalable architecture | Data scientists who want to show results quickly |
Shiny for Python vs Dash
Shiny for Python and Dash differ in their programming logic: Dash uses an explicit callback system in which it must be precisely defined which inputs influence which outputs. This provides maximum control over the data flow, but requires more manual structuring.
Here as well, Shiny for Python relies on reactive programming: dependencies between inputs and outputs are automatically detected, so that only the affected parts of the application update themselves. This results in less boilerplate code, and complex, highly interconnected interfaces can be implemented comparatively elegantly.
While Shiny is particularly well suited for dynamic, data-driven applications with many reactive elements, Dash stands out through its clear architecture and its close integration with visualizations.
| Shiny for Python | Dash | |
|---|---|---|
| Reactivity | Automatic | Explicit callbacks |
| Learning curve | Intuitiver | Clearly structured |
| Use Cases | Complex analytics and business apps with many interactive dependencies | Interactive dashboards, data-driven web apps |
| Scalability | Well suited for growing, modular apps | Highly scalable with a clean architecture design |
| Target audience | Data scientists with a need for scalable architecture | Developers and data scientists who want full control over the data flow |
Shiny for Python and Jupyter Notebooks
Shiny for Python can be used directly in Jupyter Notebook or JupyterLab, combining interactive web app functionality with the classic data science workflow. While Jupyter is primarily designed for exploratory, linear analysis, Shiny complements this approach with true reactivity: UI elements automatically respond to changes and update only the affected parts of the application. This makes Shiny in Jupyter particularly suitable for interactive data analyses, teaching purposes, and rapid prototypes. For production-grade, scalable multi-user applications, however, Shiny is usually run as a standalone web app outside of the notebook.
| Shiny for Python (in Jupyter) | Classic Jupyter Notebook | |
|---|---|---|
| Reaktivität | Automatisch | Keine echte Reaktivität, manuelles erneutes Ausführen von Zellen |
| Lernkurve | Etwas höher durch reaktives Konzept | Sehr niedrig, da lineares Skriptprinzip |
| Anwendungsfälle | Komplexe Webanwendungen | Explorative Analyse, Experimente, Dokumentation |
| Skalierbarkeit | Begrenzt im Notebook, besser als eigenständige App | Nicht für skalierbare Web-Anwendungen gedacht |
| Zielgruppe | Data Scientists mit Bedarf an interaktiven Analyse-Interfaces | Data Scientists, Forschende, Studierende für explorative Arbeit |
Shiny Express
Shiny Express ist eine vereinfachte Form von Shiny for Python, die auf eine möglichst schnelle und unkomplizierte Entwicklung interaktiver Anwendungen abzielt. Anstelle einer strikten Trennung von Oberfläche und Serverlogik nutzt es eine kompakte, skriptähnliche Herangehensweise. Dadurch entsteht weniger struktureller Aufwand und Anwendungen lassen sich mit überschaubarem Code realisieren. Besonders für kleinere Vorhaben, Demonstrationen oder den Einsatz in Lehrkontexten ist dieser Ansatz gut geeignet. Für umfangreichere Projekte bietet die klassische Shiny-Variante jedoch mehr organisatorische Klarheit und langfristige Erweiterungsmöglichkeiten.
| Shiny for Python | Shiny Express | |
|---|---|---|
| Reaktivität | Automatisch | Keine echte Reaktivität, manuelles erneutes Ausführen von Zellen |
| Lernkurve | Mittel bis höher – Reaktivitätskonzept und App-Struktur müssen verstanden werden | Niedrig – schneller Einstieg durch reduzierte Komplexität |
| Anwendungsfälle | Produktive Analyse-Tools, Business-Apps, komplexe Dashboards | Prototypen, Lehrbeispiele, schnelle Daten-Demos |
| Skalierbarkeit | Gut für langfristige, skalierbare Anwendungen | Begrenzt bei stark wachsenden Anwendungen |
| Zielgruppe | Data Scientists und EntwicklerInnen mit Struktur- und Skalierungsbedarf | EinsteigerInnen, Lehrende, schnelle Projektumsetzungen |
Shiny for Python Serverless (Shinylive)
Mit Hilfe von Shinylive und WebAssembly (Wasm) lassen sich Shiny-Apps ganz einfach in einem Browser nutzen – ohne die Notwendigkeit eines Python-Servers. Dabei wird der Python-Code direkt im Browser ausgeführt, sodass keine serverseitige Infrastruktur erforderlich ist. Jedoch muss hier ein Kompromiss geschlossen werden: Wegen der kaum möglichen Datenbereitstellungen, sind die Möglichkeiten komplexer Apps hier deutlich eingeschränkten gegenüber der klassischen Sever-Client-Architektur einer Shiny-App. Das Ergebnis ist eine statische Website, die dennoch interaktive Shiny-Funktionalität bietet. Dadurch werden Deployment, Skalierung und Wartung deutlich vereinfacht. Shinylive eignet sich besonders für öffentliche Dashboards, Dokumentationen, Lernmaterialien oder Anwendungen mit vielen gleichzeitigen Nutzenden, bei denen keine serverseitige Logik wie Datenbankzugriffe notwendig ist.
Testing mit Playwright in Shiny for Python
Playwright ist ein modernes Testwerkzeug zur automatisierten Überprüfung von Webanwendungen. Für Shiny for Python-Apps kann Playwright verwendet werden, um die Funktionalität und Interaktionen einer App automatisiert zu testen.
Dabei simuliert Playwright reale Nutzeraktionen, z.B. das Klicken auf Buttons, das Ausfüllen von Eingabefeldern oder das Navigieren durch die Oberfläche. So lässt sich überprüfen, ob die Anwendung wie erwartet reagiert und ob Änderungen im Code unbeabsichtigte Fehler verursachen.
Automatisierte Tests mit Playwright tragen somit zur Qualitätssicherung bei und unterstützen eine stabile Weiterentwicklung von Shiny-Anwendungen.
Beispiel eines Playwright-Test:
from services.data import filter_species def test_filter_species(): df = ... out = filter_species(df, "setosa") assert (out["Species"] == "setosa").all()
Tipps & Hinweise
Nutzen Sie anfangs Starter-Templates / Boilerplates um sich den Einstieg zu erleichtern z. B.
- Inline Dokumentation helfen bei der Nachvollziehbarkeit
- Schrittweise Vorgehen und bei jeder Iteration Feedback von Usern einholen
- Nutzen Sie zur Versionskontrolle verschiedene Tools wie Git
- Testing, Testing, Testing: Schreiben Sie Unit-Tests und End-to-End-Tests. Shiny for Python bietet hier ein eigenes Framework
Fazit
Mit Shiny for Python eröffnen sich für Python-EntwicklerInnen neue Möglichkeiten der Visualisierung und Interaktion mit Daten. Durch sein reaktives Programmiermodell, die klare Trennung von UI und Serverlogik sowie die gute Integration in bestehende Python-Ökosysteme eignet es sich besonders für datengetriebene Business-Anwendungen und produktionsnahe Analyse-Tools. Mit einer klaren Projektstruktur, sauber getrennten Services, konsequentem Testing und iterativer Entwicklung lassen sich Shiny-Apps nachhaltig, wartbar und teamfähig umsetzen.
Sie haben das Potenzial von Shiny for Python erkannt und möchte dieses Live erleben?
Seit über 15 Jahren sind wir der führende Anbieter für R-basierte Projekte und Shiny-App-Entwicklung – sprechen Sie uns an und gemeinsam gehen wir die nächsten Schritte.
Weiterführende Links
Veröffentlicht: 19. July 2023
AutorIn
Starten Sie jetzt durch:
Wir freuen uns auf den Austausch mit Ihnen.