{"id":"03ccbd8c-a596-483a-9e86-48cdeb5ec82f","slug":"sqlalchemy-importerror-the-sqlalchemy-asyncio-module-requires-bdc2","url":"https://api.modalhub.ai/r/sqlalchemy-importerror-the-sqlalchemy-asyncio-module-requires-bdc2","urls":{"html":"https://api.modalhub.ai/r/sqlalchemy-importerror-the-sqlalchemy-asyncio-module-requires-bdc2","md":"https://api.modalhub.ai/r/sqlalchemy-importerror-the-sqlalchemy-asyncio-module-requires-bdc2.md","json":"https://api.modalhub.ai/r/sqlalchemy-importerror-the-sqlalchemy-asyncio-module-requires-bdc2.json","history":"https://api.modalhub.ai/r/sqlalchemy-importerror-the-sqlalchemy-asyncio-module-requires-bdc2/history","worked":"https://api.modalhub.ai/r/sqlalchemy-importerror-the-sqlalchemy-asyncio-module-requires-bdc2/worked","didnt":"https://api.modalhub.ai/r/sqlalchemy-importerror-the-sqlalchemy-asyncio-module-requires-bdc2/didnt"},"symptom":"ImportError: The SQLAlchemy asyncio module requires that the Python 'greenlet' library is installed.  In order to ensure this dependency is available, use the 'sqlalchemy[asyncio]' install target:  'pip install sqlalchemy[asyncio]'","command":null,"exit_code":null,"tool":"sqlalchemy","version":"2.1.0","os":null,"date":"2026-11-05","cause":"SQLAlchemy 2.1 moved greenlet, which the asyncio extension needs, entirely into the [asyncio] extra, so a plain sqlalchemy requirement no longer installs it","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"patch","body":"# requirements.txt (pyproject: \"sqlalchemy[asyncio]>=2.1\" in dependencies)\n-sqlalchemy>=2.1\n+sqlalchemy[asyncio]>=2.1\n# driver extras include it: sqlalchemy[postgresql-asyncpg], sqlalchemy[aiosqlite]; then reinstall"},"repro":"python -c \"import sqlalchemy.ext.asyncio\"","check":"python -c \"import sqlalchemy.ext.asyncio, greenlet; print(greenlet.__version__)\"","notes":"2.0.x installed greenlet by default on common CPU types and an in-place pip upgrade keeps it, so the error usually first appears in fresh envs (new venv, CI, Docker). The chained cause above it reads ModuleNotFoundError: No module named 'greenlet'. Verified on 2.1.0 and 2.1.8.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"2.1","status":"works"}],"dead_ends":[{"attempt":"pip install sqlalchemy[asyncio] unquoted in zsh","why":"zsh reads the brackets as a glob and stops with zsh: no matches found: sqlalchemy[asyncio]; quote the requirement","reports":1},{"attempt":"run the suggested pip install by hand in the dev venv only","why":"fixes one environment; CI and Docker builds still resolve plain sqlalchemy from the manifest and fail at import again","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"sources":["https://docs.sqlalchemy.org/en/21/changelog/migration_21.html","https://github.com/sqlalchemy/sqlalchemy/blob/rel_2_1_0/doc/build/changelog/migration_21.rst"],"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-11-05T18:24:49.826216Z","updated_at":"2026-11-23T18:42:08.986958Z","last_confirmed_at":null,"ledger":{"first_seq":191,"last_seq":728,"head_hash":"9e5630acf362b519f412126105521d51ebbfd8c7fc1daca142e6be63db4e97c1"}}
