Solara Server
Solara server is a Python package that enables running ipywidgets-based web applications without the need for a full Jupyter kernel. It supports multiple 'Virtual Kernels' to share the same process, enhancing performance and scalability. This makes it ideal for deploying Solara applications as standalone web apps, often integrating with frameworks like Starlette, FastAPI, or Flask. The current version is 1.57.3, and it receives regular updates, often in conjunction with the main `solara` library.
Common errors
-
ERROR: Exception in ASGI application ...... ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)
cause This error, often accompanied by long loading times, can occur when Solara tries to access CDNs for assets even after `solara[assets]` has been installed, particularly in environments with strict network policies or self-signed certificates.fixEnsure all required assets are bundled locally by installing with `pip install "solara[assets]"`. If the issue persists, it might indicate an underlying network or certificate configuration problem that prevents local asset resolution or external CDN access. -
Solara app in Jupyter notebook does not display, or interactive components are not responsive.
cause The most common cause is a discrepancy in Python environments, where the Jupyter notebook server and the kernel are using different installations, and required JavaScript dependencies (like ipyvue, ipyvuetify) are not available in the server's environment.fixInstall `solara ipyvue ipyvuetify` (or simply `solara`) in the Python environment *used by the Jupyter server itself*, not just the kernel. You might need to identify the server's Python executable path and use it to install the packages. -
Starlette 1.0 breaks Solara import: Starlette.__init__() no longer accepts on_startup / on_shutdown.
cause An incompatibility with Starlette version 1.0 where the `__init__` method of Starlette applications has removed the `on_startup` and `on_shutdown` parameters, which Solara Server's integration expects.fixDowngrade Starlette to a version prior to 1.0 (e.g., `pip install 'starlette<1.0'`). This issue will require an update from the Solara development team for full Starlette 1.0 compatibility.
Warnings
- breaking Solara 2.0 (planned release end of year) introduces significant changes to reactive state management, including default state mutation detection and altered behavior for reactive variables in boolean comparisons. These changes can be enabled in Solara >= 1.41.0/1.42.0 via environment variables but will be default in 2.0.
- breaking Integration with Starlette 1.0 is currently broken as `Starlette.__init__()` no longer accepts `on_startup` or `on_shutdown` arguments.
- gotcha Solara Server collects anonymous usage telemetry by default using Mixpanel. This tracks server start/stop and daily unique users/connections.
- gotcha When running Solara applications within Jupyter environments, a common issue is a mismatch between the Python environment of the notebook server and the kernel, leading to UI components not loading correctly (e.g., missing Javascript libraries for `ipyvue`, `ipyvuetify`).
- gotcha Solara Server keeps virtual kernels alive for 24 hours after a WebSocket disconnection by default (e.g., browser tab closed or computer hibernates). While useful for re-establishing connections, it can consume memory.
Install
-
pip install solara-server -
pip install "solara-server[starlette]" -
pip install solara
Imports
- solara run
solara run my_app.py
- app (for embedding)
from solara_server import app
from solara.server.starlette import app as solara_app
Quickstart
import solara
clicks = solara.reactive(0)
@solara.component
def Page():
def increase_clicks():
clicks.value += 1
solara.Button(label=f"Clicked {clicks} times", on_click=increase_clicks)
# To run this application, save it as `sol.py` and execute `solara run sol.py` in your terminal.