Repair ComfyUI Portable Dependencies One Module at a Time
A tested Windows portable ComfyUI repair transcript for missing SQLAlchemy, torch, frontend package, kornia, PyOpenGL, and other startup dependencies.
When a Windows portable ComfyUI environment starts failing with missing core packages, do not begin with a broad reinstall. The safer loop:
- start ComfyUI
- read the first new blocker in the log
- install only that package in
python_embeded - start again
- repeat until the server,
/system_stats,/object_info, andpip checkare healthy
Practical rule
Run one install, then restart and read the new log. A copied error should lead to the exact package that changed the next startup attempt, not to a giant command that hides what actually fixed the environment.
When to use this runbook
Use it when the environment itself is missing core startup dependencies in sequence:
| Current evidence | Better path |
|---|---|
Startup stops before Starting server and each restart exposes a new core missing package | Use this one-package-at-a-time loop |
Only one custom node shows IMPORT FAILED | Use Plugin Import Failed first |
| The workflow has red nodes but ComfyUI starts cleanly | Use Missing Nodes, then verify plugin registration |
| Torch imports but CUDA is unavailable | Use Torch Not Compiled With CUDA Enabled before adding more packages |
| Nodes are registered but model files are missing | Use Where to Put Safetensors or Cannot Find Model File |
Verification rule: offline import success, an open browser tab, or a "package installed" message is not enough. The repaired environment must be the process that started ComfyUI, own the expected port, expose /system_stats and /object_info, and pass runtime checks.
A documented repair chain
This is a real one-package-at-a-time sequence from a repaired portable environment (started at ModuleNotFoundError: No module named 'sqlalchemy', recovered on an RTX 4070 Ti SUPER with CUDA PyTorch). Your exact chain will differ.
| Attempt | First new signal in the log | One package action | What changed after restart |
|---|---|---|---|
| 1 | ModuleNotFoundError: No module named 'sqlalchemy' | pip install "SQLAlchemy>=2.0" | exposed filelock |
| 2 | ModuleNotFoundError: No module named 'filelock' | pip install filelock | exposed alembic and yaml |
| 3 | Error importing dependencies: No module named 'alembic' | pip install alembic | database setup moved forward |
| 4 | ModuleNotFoundError: No module named 'yaml' | pip install PyYAML | exposed PIL |
| 5 | ModuleNotFoundError: No module named 'PIL' | pip install Pillow | exposed tqdm |
| 6 | ModuleNotFoundError: No module named 'tqdm' | pip install tqdm | exposed comfy_aimdo |
| 7 | ModuleNotFoundError for an unfamiliar internal-looking module | Check the matching local requirement or official ComfyUI package metadata before installing anything | Avoids guessing a package name from an import name |
| 8 | ModuleNotFoundError: No module named 'torch' | Follow ComfyUI Torch Missing to select a matching CUDA wheel in the embedded Python | CUDA is verified before the next repair |
| 9 | ModuleNotFoundError: No module named 'safetensors' | pip install safetensors | exposed packaging |
| 10 | ModuleNotFoundError: No module named 'packaging' | pip install packaging | exposed numpy |
| 11 | ModuleNotFoundError: No module named 'numpy' | pip install "numpy>=1.25.0" | exposed einops |
| 12 | ModuleNotFoundError: No module named 'einops' | pip install einops | exposed psutil |
| 13 | ModuleNotFoundError: No module named 'psutil' | pip install psutil | reached VRAM detection, then exposed torchvision |
| 14 | ModuleNotFoundError: No module named 'torchvision' | installed torchvision from the same CUDA wheel index | exposed torchaudio |
| 15 | ModuleNotFoundError: No module named 'torchaudio' | installed torchaudio from the same CUDA wheel index | exposed scipy |
| 16 | ModuleNotFoundError: No module named 'scipy' | pip install scipy | exposed transformers |
| 17 | ModuleNotFoundError: No module named 'transformers' | pip install transformers | exposed torchsde |
| 18 | ModuleNotFoundError: No module named 'torchsde' | pip install torchsde | exposed av |
| 19 | ModuleNotFoundError: No module named 'av' | pip install av | exposed aiohttp |
| 20 | ModuleNotFoundError: No module named 'aiohttp' | pip install aiohttp | exposed requests |
| 21 | ModuleNotFoundError: No module named 'requests' | pip install requests | exposed pydantic |
| 22 | ModuleNotFoundError: No module named 'pydantic' | pip install pydantic | exposed comfyui-frontend-package |
| 23 | comfyui-frontend-package is not installed | pip install comfyui-frontend-package | server started, but some built-in extra nodes failed to import |
Once the server was alive, the cleanup pass continued in the same style:
| Cleanup signal | One package action | Result |
|---|---|---|
No module named 'kornia' in post-processing/canny/morphology nodes | pip install kornia | node count rose from 657 to 685 |
No module named 'spandrel' in nodes_upscale_model.py | pip install spandrel | node count rose to 687 |
repeated No module named 'pydantic_settings' while parsing pyproject.toml | pip install pydantic-settings | startup log shrank to a short warning set |
OpenGL dependencies not available | pip install PyOpenGL, restart, then pip install glfw | GLSL/OpenGL node imported |
No module named 'simpleeval' in nodes_math.py | pip install simpleeval | no IMPORT FAILED lines remained |
comfyui-workflow-templates is not installed | pip install comfyui-workflow-templates | template warning disappeared |
comfyui-embedded-docs package not found | pip install "comfyui-embedded-docs==0.4.4" | embedded docs warning disappeared |
WARNING: blake3 package not installed | pip install blake3 | blake3 warning disappeared |
| An unfamiliar ComfyUI-internal package fails to import | Check the local ComfyUI requirements and official release metadata before installing | Avoids pulling an unrelated PyPI package by name |
The final log still reported the comfy_kitchen Triton backend as unavailable because triton was not installed. That was not a startup blocker — the CUDA and eager backends were available and the server opened normally.
Step 0: Start from the portable root
Open PowerShell in the folder that contains run_nvidia_gpu.bat, run_cpu.bat, python_embeded, and ComfyUI. Confirm the Python executable:
.\python_embeded\python.exe -s -c "import sys; print(sys.executable); print(sys.version)"If this path is not the Python that starts ComfyUI, switch to the right environment.
Step 1: Capture each attempt
$ts = Get-Date -Format 'yyyyMMdd_HHmmss'
New-Item -ItemType Directory -Force .\repair_logs | Out-Null
$out = ".\repair_logs\attempt_${ts}_stdout.log"
$err = ".\repair_logs\attempt_${ts}_stderr.log"
Start-Process -FilePath ".\python_embeded\python.exe" `
-ArgumentList @("-s", "ComfyUI\main.py", "--windows-standalone-build") `
-WorkingDirectory (Get-Location) `
-RedirectStandardOutput $out `
-RedirectStandardError $err `
-PassThruThen read the bottom of the stderr log (Get-Content $err -Tail 200), install only the package named by the first real blocker, and start again with a new log.
Step 2: Do not trust port 8188 until you check ownership
http://127.0.0.1:8188/ can return 200 from another ComfyUI process in a different folder. Check ownership before declaring success:
Get-NetTCPConnection -LocalPort 8188 -ErrorAction SilentlyContinue |
Select-Object LocalAddress,LocalPort,State,OwningProcess
Get-CimInstance Win32_Process |
Where-Object { $_.CommandLine -like "*ComfyUI*main.py*" } |
Select-Object ProcessId,CommandLineIf 8188 is occupied, start the broken environment on a clean port while repairing:
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --port 8191Only the process from the same portable root counts as proof.
Step 3: Verify Torch before and after installing it
If the log says No module named 'torch', a default-index install can satisfy the import while giving you a CPU-only build. Select the matching CUDA wheel from the official PyTorch selector and run it through the embedded Python:
.\python_embeded\python.exe -s -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cuXXXReplace cuXXX with the CUDA wheel tag for your supported PyTorch build. Do not add a third-party package mirror to this primary command. Then verify:
.\python_embeded\python.exe -s -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'no cuda')"Continue only when this shows a non-None CUDA version and True for CUDA availability.
Step 4: Treat frontend and template packages as ComfyUI versioned packages
When the log says comfyui-frontend-package is not installed., look at your own ComfyUI\requirements.txt before choosing versions. Installing the frontend package unpinned may give a newer frontend than required_frontend_version; it can work, but the safer instruction is to copy the versions your local ComfyUI code pins. The same applies to comfyui-frontend-package, comfyui-workflow-templates, and comfyui-embedded-docs.
Step 5: Verify recovery with more than the browser
Final start on a clean port:
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --port 8191Healthy signals include Starting server, a Device: cuda:0 line with your GPU, and the frontend version. Then verify endpoints:
Invoke-RestMethod http://127.0.0.1:8191/system_stats
Invoke-RestMethod http://127.0.0.1:8191/object_info
.\python_embeded\python.exe -s -m pip checkA healthy result reports the expected CUDA/Torch runtime, /object_info node count, present core nodes (CheckpointLoaderSimple, KSampler), and pip check: No broken requirements found.
Blocker or warning?
| Log line | Blocker? | What to do |
|---|---|---|
ModuleNotFoundError: No module named 'sqlalchemy' before server start | Yes | Install SQLAlchemy in the embedded Python, then restart |
ModuleNotFoundError: No module named 'torch' | Yes | Install Torch, then verify CUDA, not just import success |
comfyui-frontend-package is not installed | Yes | Install the frontend package required by local ComfyUI |
IMPORT FAILED: nodes_math.py | Partial | Server can start, but that node is missing; install simpleeval |
Starting server appears | No | Continue with endpoint verification |
Found comfy_kitchen backend triton: {'available': False, ...} | Usually no | Ignore unless a workflow requires Triton |
/system_stats returns the expected GPU | No | Good sign the runtime is alive |
One package at a time or requirements all at once?
| Situation | Better move |
|---|---|
| Diagnosing an unknown broken portable environment | One package, restart, read the next log |
| The first error is a custom node missing one package | Install that node's package or requirements |
| Torch imports but CUDA is false | Fix the CUDA Torch wheel first |
| Torch/CUDA is healthy | Avoid broad commands that may replace it |
| Creating a fresh clean environment | pip install -r ComfyUI\requirements.txt can be normal |
A blind pip install -r ComfyUI\requirements.txt can be acceptable for a clean manual install, but it is not the best forensic repair loop when you need to understand what broke.
What not to do
- do not use system
pipwhen ComfyUI usespython_embeded - do not assume a browser page on 8188 belongs to the environment you are repairing
- do not treat CPU Torch import success as CUDA success
- do not paste a long package list when you are trying to learn the next log change
- do not treat every warning after
Starting serveras fatal - do not delete the environment before preserving workflows, models, and custom nodes
Related Guides
- ModuleNotFoundError: No module named 'sqlalchemy' in ComfyUI
- comfyui-frontend-package is not installed in ComfyUI
- ModuleNotFoundError: No module named 'torch' in ComfyUI
- ModuleNotFoundError: No module named 'transformers' in ComfyUI
- ModuleNotFoundError: No module named 'kornia' in ComfyUI
- ModuleNotFoundError: No module named 'spandrel' in ComfyUI
- ModuleNotFoundError: No module named 'pydantic_settings' in ComfyUI
- ModuleNotFoundError: No module named 'simpleeval' in ComfyUI
- OpenGL dependencies not available in ComfyUI
- ComfyUI Startup Failed
- ComfyUI Dependency Conflicts
- ModuleNotFoundError: No module named 'triton' in ComfyUI
- Torch Not Compiled With CUDA Enabled
Source References
Start free with Wonderful Launcher if this affects your real ComfyUI environment. It keeps launcher-native repair, task logs, and runtime checks in one place; credits are only for image generation and metered tools.
Download Wonderful LauncherSee credit packagesDid this fix your issue?
Your answer helps prioritize verified ComfyUI repairs.