ComfyUI: ModuleNotFoundError: No module named 'safetensors' (fix)

ModuleNotFoundError: No module named 'safetensors' stops ComfyUI at startup, before any model or custom node loads. We reproduced it on ComfyUI v0.37.0 and fixed it.

1. The error

ComfyUI v0.37.0 started in a venv where everything from requirements.txt is installed except safetensors:

python main.py
Traceback (most recent call last):
  File "/path/to/ComfyUI/main.py", line 249, in <module>
    import comfy.utils
  File "/path/to/ComfyUI/comfy/utils.py", line 27, in <module>
    import safetensors.torch
ModuleNotFoundError: No module named 'safetensors'

ComfyUI exited with code 1 before loading any nodes: main.py line 249 imports comfy/utils.py, which does import safetensors.torch at line 27 (it reads .safetensors model files). safetensors is listed in ComfyUI's requirements.txt, and transformers and spandrel depend on it too, so seeing it missing usually means the requirements were never installed into the Python that runs ComfyUI, or something uninstalled it.

2. Fix: install requirements.txt with the same Python

From the ComfyUI folder, using the Python that starts ComfyUI (your venv's python; in the Windows portable build, ..\python_embeded\python.exe run from inside the ComfyUI folder):

python -m pip install -r requirements.txt
Collecting safetensors>=0.4.2 (from -r requirements.txt (line 13))
  Downloading safetensors-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.2 kB)
Downloading safetensors-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (516 kB)
Installing collected packages: safetensors
Successfully installed safetensors-0.8.0

(pip also printed a dependency warning about packages of unrelated custom nodes in our test venv; we left it out.) Started again, ComfyUI loaded all nodes and exited 0 (--quick-test-for-ci):

[INFO] Context impl SQLiteImpl.
[INFO] Will assume non-transactional DDL.
[INFO] Using RAM pressure cache.

If pip says safetensors is already installed and the error stays, you are installing into a different Python than the one running ComfyUI. See ComfyUI: No module named 'yaml' for how to find the right one.

Related: ComfyUI: No module named 'tqdm' · ComfyUI: No module named 'transformers' · ComfyUI: No module named 'requests' · ComfyUI: No module named 'sqlalchemy'

Frequently asked questions

Is safetensors required by ComfyUI?

Yes. It is in requirements.txt and comfy/utils.py imports it during startup, so ComfyUI exits with code 1 without it.

I installed safetensors but still get the error. Why?

It went into a different Python. Run python -m pip with the same python (or python_embeded\python.exe) that starts ComfyUI.

Written with AI assistance. Measured on 2026-10-24 on Linux, CPython 3.11.17, pip 26.2.2: ComfyUI v0.37.0 with torch 2.9.0+cpu, without safetensors and after pip install -r requirements.txt (safetensors 0.8.0). Output pasted unedited except shortened paths and one omitted pip warning. PlainTables is our extension; ComfyUI and safetensors are free.