LogoWonderful Launcher
  • Product
  • Pricing
  • Solutions
  • Docs
  • Blog
  • Get Help
  • Download

No module named 'sqlalchemy' in ComfyUI

Needs verification

Fix No module named 'sqlalchemy' in ComfyUI portable builds and learn when it means more core dependencies are missing.

If ComfyUI stops with ModuleNotFoundError: No module named 'sqlalchemy', treat it as a core startup dependency problem first.

This is usually not a custom node asking for an optional package. In current ComfyUI builds, SQLAlchemy can be imported by ComfyUI's asset database code during startup. If it is missing, ComfyUI can stop before it reaches the browser UI.

Fast answer

For the GitHub Windows portable package, run these commands from the portable root, the folder that contains run_*.bat, python_embeded, and ComfyUI:

.\python_embeded\python.exe -s -m pip show SQLAlchemy alembic
.\python_embeded\python.exe -s -m pip install "SQLAlchemy>=2.0" alembic
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build

If the next launch fails on another core package, do not keep guessing one package at a time. Use the broader portable dependency repair runbook.

What The Error Looks Like

In a real Windows portable repair, the first blocking traceback looked like this:

File "...\ComfyUI\app\assets\database\queries\asset.py", line 1, in <module>
  import sqlalchemy as sa
ModuleNotFoundError: No module named 'sqlalchemy'

The important detail is where it happens. The import comes from ComfyUI's own app\assets startup path, not from a single custom node folder.

Quick Diagnosis

What You SeeMeaningFirst Action
No module named 'sqlalchemy' before Starting serverCore dependency missingInstall SQLAlchemy in ComfyUI's Python
Traceback points to app\assets\databaseComfyUI core startup path failedCheck ComfyUI requirements, not a random plugin
Fixing SQLAlchemy reveals comfyui-frontend-package is not installedMore core requirements are missingContinue with the portable dependency repair runbook
pip show SQLAlchemy works in system Python but ComfyUI still failsInstalled into the wrong PythonUse python_embeded\python.exe or the active venv
Torch and CUDA still import correctlyGPU stack may be healthyDo not reinstall Torch blindly

Step 1: Use The Python That Starts ComfyUI

Most failed repairs happen because the command installs into the wrong Python environment.

For the GitHub Windows portable package, run from the extracted portable root:

.\python_embeded\python.exe -s -c "import sys; print(sys.executable)"
.\python_embeded\python.exe -s -m pip show SQLAlchemy alembic

For a manual Git install, activate the venv first:

.\venv\Scripts\activate
python -c "import sys; print(sys.executable)"
python -m pip show SQLAlchemy alembic

For ComfyUI Desktop or another managed launcher, use the app's own terminal or environment tools. Do not assume the portable python_embeded path exists.

Step 2: Install The Missing Core Dependency

For Windows portable:

.\python_embeded\python.exe -s -m pip install "SQLAlchemy>=2.0" alembic

For a manual venv:

python -m pip install "SQLAlchemy>=2.0" alembic

Why include alembic? ComfyUI's current requirements list both database packages together. If SQLAlchemy disappeared, Alembic may be missing too, and the next startup can fail later in the same database path.

Step 3: Restart And Read The Next First Error

Start ComfyUI again:

.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build

Success looks like this:

Starting server
To see the GUI go to: http://127.0.0.1:8188

If the next error says comfyui-frontend-package is not installed, move to comfyui-frontend-package is not installed in ComfyUI.

If the next error is another missing core dependency from ComfyUI\requirements.txt, use Repair Broken ComfyUI Portable Dependencies Without Reinstalling Torch. That page covers the case where SQLAlchemy is only the first visible missing package.

Step 4: Check Whether Torch Is Still Healthy

Before running broad dependency commands, check the GPU stack:

.\python_embeded\python.exe -s -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available())"

If this prints a CUDA-enabled PyTorch build and True, protect that stack. Do not reinstall Torch just because SQLAlchemy is missing.

If it prints False, or Torch cannot import, use Torch not compiled with CUDA enabled before chasing smaller package errors.

What Not To Do

Avoid these shortcuts while fixing this error:

  • do not run plain pip install sqlalchemy from system Python if ComfyUI uses embedded Python
  • do not delete ComfyUI before reading the first traceback
  • do not reinstall Torch or CUDA just to fix a database package
  • do not assume the last visible error is the first real error
  • do not keep installing packages one by one if many ComfyUI requirements are missing

How Wonderful Launcher Helps

This is exactly the kind of failure where logs matter. Wonderful Launcher helps by keeping startup logs, environment boundaries, and recovery work visible instead of forcing you to guess which Python received the package.

If your environment keeps moving from one missing package to another, the bigger problem is probably dependency drift, not SQLAlchemy alone.

Related Guides

  • Repair Broken ComfyUI Portable Dependencies Without Reinstalling Torch
  • comfyui-frontend-package is not installed in ComfyUI
  • ComfyUI Startup Failed
  • ComfyUI Dependency Conflicts
  • Torch Not Compiled With CUDA Enabled

Source References

  • Windows portable repair lab, May 18, 2026: startup log showed ModuleNotFoundError: No module named 'sqlalchemy' from ComfyUI\app\assets\database\queries\asset.py
  • Same lab ComfyUI\requirements.txt: SQLAlchemy>=2.0 and alembic
  • Same lab verification: ComfyUI reached http://127.0.0.1:8188 after core dependency repair and frontend package repair

You can fix it manually, or download Wonderful Launcher for Windows to diagnose plugin errors, missing dependencies, and broken ComfyUI environments without reinstalling.

Download free for Windows

Did this fix your issue?

Your answer helps prioritize verified ComfyUI repairs.

Table of Contents

What The Error Looks Like
Quick Diagnosis
Step 1: Use The Python That Starts ComfyUI
Step 2: Install The Missing Core Dependency
Step 3: Restart And Read The Next First Error
Step 4: Check Whether Torch Is Still Healthy
What Not To Do
How Wonderful Launcher Helps
Related Guides
Source References