solara
solara copied to clipboard
ImportError: cannot import name 'LOOP_CHOICES' from 'uvicorn.main' when using Python 3.14
Solara fails to start on Python 3.14 due to importing deprecated LOOP_CHOICES constant from uvicorn that has been removed.
Expected behavior
Solara should successfully import and run on Python 3.14 without import errors from uvicorn dependencies.
Current behavior
When running Solara on Python 3.14, the application fails to start with an ImportError:
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.14.0/x64/bin/solara", line 3, in <module>
from solara.__main__ import main
File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/solara/__main__.py", line 16, in <module>
from uvicorn.main import LEVEL_CHOICES, LOOP_CHOICES
ImportError: cannot import name 'LOOP_CHOICES' from 'uvicorn.main' (/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/uvicorn/main.py)
The issue is that LOOP_CHOICES has been removed from uvicorn's public API in recent versions.
Steps to reproduce the problem
- Install Python 3.14
- Install Solara:
pip install solara - Run any Solara command:
solara run app.py - Observe the ImportError on startup
Specifications
- Solara Version: master
- Platform: Linux (GitHub Actions hosted runner)
- Affected Python Versions: Python 3.14.0
Potential solution
Update solara/__main__.py line 16 to handle the missing LOOP_CHOICES import:
from uvicorn.main import LEVEL_CHOICES
# LOOP_CHOICES was removed from uvicorn, define it locally for backward compatibility
try:
from uvicorn.main import LOOP_CHOICES
except ImportError:
# Fallback for newer uvicorn versions
LOOP_CHOICES = click.Choice(["auto", "asyncio", "uvloop"])
Same issue with other Python versions: https://github.com/widgetti/solara/issues/1101
Pinning uvicorn<0.30 resolves the issue.
actually uvicorn==0.35 is the last supported version apparently.. above that things break, although I have found a way to bypass the issue with the latest version of uvicorn . If anyone is interested, i can share
Fixed in #1113