Skip to content

ImportError: cannot import name 'LOOP_CHOICES' from 'uvicorn.main' when using Python 3.14 #1109

@EwoutH

Description

@EwoutH

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

  1. Install Python 3.14
  2. Install Solara: pip install solara
  3. Run any Solara command: solara run app.py
  4. 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"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions