ComfyLab
ComfyUI "Import Failed" / Custom Node Errors: How to Actually Fix Them

ComfyUI "Import Failed" / Custom Node Errors: How to Actually Fix Them

4GB VRAM VRAM Beginner 9 min Any
Savien

When you install a custom node into ComfyUI and see “ModuleNotFoundError: No module named insightface” or a generic “Import Failed” message, you’re looking at the same problem 99% of the time: a missing Python dependency. The node’s code is sitting there, but the libraries it needs aren’t installed where ComfyUI can find them. This guide walks you through diagnosing and fixing ComfyUI import failed errors, ComfyUI ModuleNotFoundError, and other custom node errors without guessing.

This isn’t another generic troubleshooting article. Instead, it covers the real mistakes that cause these problems—and how to stop them from happening again.

At a Glance: Common ComfyUI Custom Node Errors

Error TypeRoot CauseQuick Fix
ModuleNotFoundErrorMissing Python libraryActivate venv, then pip install <module>
Import Failed (no details)Wrong Python environmentCheck terminal output; verify venv is active
Module installed but still missingInstalled in system Python, not ComfyUI’s venvActivate venv, reinstall
Compilation error (Windows)Missing Visual C++ Build ToolsDownload from visualstudio.microsoft.com
Version conflictIncompatible library versionInstall specific version: pip install module==X.X.X

Why Custom Node Errors Happen

ComfyUI works in modules. The core runs fine on its own, but custom nodes depend on external Python libraries that don’t ship with it. When you git clone a node, you’re getting the code files only—not the dependencies.

Take a face-detection node. It needs insightface. A pose estimator needs mediapipe. A YOLO detector needs ultralytics. Each of these has to be installed separately into the same Python environment ComfyUI uses. Skip that step, and the import fails before the node even loads.

Here’s the good news: the error message is usually telling you exactly what’s missing. The trick is knowing where to install it and avoiding the wrong Python environment.

💡 Tip: Custom node errors stem from dependencies not being in ComfyUI’s Python environment. The error message shows you what’s missing—you just need to put it in the right place.


The Standard Fix: Using requirements.txt

Most well-built custom nodes ship with a requirements.txt file listing their dependencies. This is your most reliable path to fixing ComfyUI custom node errors.

Step-by-Step Installation

Step 1: Open a terminal in the custom node’s folder

Navigate to that specific node:

cd path/to/ComfyUI/custom_nodes/node_name

If you installed something called “ComfyUI-FaceTools”:

cd ComfyUI/custom_nodes/ComfyUI-FaceTools

Step 2: Activate the correct virtual environment

This part matters. You need to use the same Python environment ComfyUI runs in. Activating the venv tells pip where to actually put the packages.

On Windows:

..\..\venv\Scripts\activate

On macOS or Linux:

../../../venv/bin/activate

You’ll see (venv) at the start of your prompt when it works:

(venv) C:\Users\username\ComfyUI\custom_nodes\ComfyUI-FaceTools>

Step 3: Install the dependencies

pip install -r requirements.txt

Wait for “Successfully installed” messages. Depending on what’s in there, this can take a few minutes.

Step 4: Restart ComfyUI

Close everything—the browser tab and the terminal running the server. Wait 10 seconds. Start it back up. The node should load without errors now.

💡 Tip: The venv activation is where most people slip up. Always activate first, and look for (venv) in your prompt to confirm.


When There’s No requirements.txt

No requirements file? Check the node’s README or documentation for a dependency list. Install them manually, one by one, with the venv activated.

Common Modules and Installation Commands

Module NameInstallation CommandUsed For
insightfacepip install insightface onnxruntimeFace detection and recognition
mediapipepip install mediapipePose, hand, and face detection
ultralyticspip install ultralyticsYOLO object detection
transformerspip install transformersHuggingFace AI models
acceleratepip install accelerateTransformer optimization
opencv-pythonpip install opencv-pythonComputer vision and image processing
pillowpip install pillowImage manipulation
torchpip install torch torchvisionDeep learning framework
numpypip install numpyNumerical computing

⚠️ Important: Package names don’t always match what you import. If the error says “No module named cv2,” you install opencv-python. When in doubt, search pypi.org—it’s the definitive source.


Using ComfyUI Manager (Easier for Beginners)

Prefer avoiding the terminal? ComfyUI Manager can handle dependency installation for you. This is the simplest way to fix ComfyUI missing dependencies without managing the virtual environment yourself.

  1. Open ComfyUI Manager (button in the interface)
  2. Find “Install pip packages” in the menu
  3. Type the missing module name (e.g., “insightface”)
  4. Let Manager install it—it automatically picks the right environment
  5. Check the “Missing nodes” tab to see what’s absent and bulk-install them

Manager handles venv activation behind the scenes, so you sidestep the most common mistake: installing into the system Python instead.


Troubleshooting: When Installation Doesn’t Work

The Module Installed But ComfyUI Still Can’t Find It

What happened: You installed it into your system Python, not ComfyUI’s venv.

How to check:

  • Open a terminal with the venv active
  • Run pip show module_name
  • Look at the “Location” field

If it points somewhere outside your ComfyUI folder (like C:\Program Files or /usr/local), it’s in the wrong place.

How to fix:

  1. Activate the venv again (see Step 2 above)
  2. Run pip uninstall module_name to remove the system copy
  3. Run pip install module_name to install in the right venv location
  4. Fully restart ComfyUI

Version Conflicts and Incompatible Dependencies

A module might be installed but in a version that doesn’t work. This happens often with transformers, numpy, and torch.

Check what you have:

pip show module_name

If the node needs a specific version, install that:

pip install transformers==4.30.0

Look in the node’s documentation or GitHub issues to see what versions it actually needs.

Windows: Visual C++ Build Tools Missing

Some modules like insightface and dlib compile C++ code during installation. On Windows, missing Visual C++ Build Tools will break this.

  1. Go to visualstudio.microsoft.com
  2. Download “Build Tools for Visual Studio”
  3. Check the “Desktop development with C++” workload during setup
  4. Finish the installation (it’s free)
  5. Restart your terminal and try pip install insightface again

This fixes most Windows installation failures for compiled packages.

The Error Persists After All That

  1. Double-check the module landed in the right place:

    pip show module_name

    The “Location” should be inside your ComfyUI folder.

  2. Fully close ComfyUI—browser and terminal both. Wait 10 seconds. Restart it.

  3. Install each dependency separately, waiting for each to finish:

    pip install insightface
    pip install onnxruntime
    pip install mediapipe

    This tells you which one is actually failing.

  4. Check the terminal where ComfyUI runs. The full error message usually shows up there with the exact missing module or what went wrong during compilation.


Preventing Future Issues

  • Read the README before installing a node. Understand what it needs and any special setup.
  • Keep pip fresh: pip install --upgrade pip. Outdated pip versions sometimes can’t install certain packages.
  • If pip hangs during installation, press Ctrl+C to cancel, then try: pip install --no-cache-dir module_name. This bypasses cache problems.
  • Activate the venv first, every time. Make it muscle memory before running any pip command.
  • Bookmark PyPI (pypi.org). When an import error pops up, search the module name there to find the right installation command.

Frequently Asked Questions

Q: Can I install dependencies without touching the terminal?

A: Yes. ComfyUI Manager has an ‘Install pip packages’ option. Type the missing module and Manager installs it in the right place. Also check the ‘Missing nodes’ tab—it auto-detects what’s absent.

Q: I ran pip install but the error didn’t go away. What’s happening?

A: You probably installed into system Python instead of the venv. Activate the virtual environment first: on Linux/Mac, source venv/bin/activate; on Windows, venv\Scripts\activate. Then run pip install. Verify with which python (Linux) or where python (Windows) that it points inside the venv folder.

Q: Why does insightface fail even after I install it?

A: insightface needs Microsoft Visual C++ Build Tools on Windows. Download them from visualstudio.microsoft.com (Build Tools for Visual Studio, select ‘Desktop development with C++’ workload). Without this, C++ compilation fails even if pip says everything’s fine.

Q: What if two custom nodes need different versions of the same library?

A: That’s a dependency conflict, common with transformers or numpy. Try: (1) install the newest version both can use, (2) use a separate venv for one of them, or (3) report it to the node author on GitHub.

Q: The node says “Import Failed” but doesn’t say which module. How do I find out?

A: Look at the terminal where ComfyUI is running—the full error message usually appears there, showing the exact missing module. If not, check the node’s GitHub for a requirements.txt or README listing dependencies.

Q: I installed the module but the node still shows as missing. What’s going on?

A: Fully restart ComfyUI. Close the browser and the terminal. Wait 10 seconds. Reopen. ComfyUI loads nodes on startup, so it needs a fresh start to see newly installed dependencies.


Keep Reading

If you haven’t set up ComfyUI Manager yet, start with our guide to installing custom nodes in ComfyUI — it covers the install flow that leads to most of these errors in the first place. Dependency errors during a fresh install often trace back to a CUDA/PyTorch mismatch — see our Torch not compiled with CUDA fix if that’s what you’re seeing.


🏆 Our Recommendation

New to ComfyUI and want to avoid the terminal: Use ComfyUI Manager’s “Install pip packages” feature. It handles venv activation automatically and cuts out the most common mistakes.

Comfortable with terminals and want full control: Follow the requirements.txt method (Step 1–4 above). It’s more transparent and shows you exactly what’s being installed.

Stuck with persistent errors: Head straight to troubleshooting. In nine out of ten cases, the issue is either (1) the wrong Python environment, (2) missing compilation tools on Windows, or (3) a version conflict. Verify your venv with which python or where python—this single check solves most ComfyUI ModuleNotFoundError problems.

FAQ

Can I install dependencies without using the terminal?
Yes. ComfyUI Manager has an 'Install pip packages' option in its menu. Type the missing module's name and Manager installs it in the correct environment. Also check the 'Missing nodes' tab, which auto-detects what's absent.
I ran pip install but it's still the same error. Why?
You likely installed into the system Python instead of ComfyUI's venv. Activate the virtual environment first: on Linux/Mac, 'source venv/bin/activate'; on Windows, 'venv\Scripts\activate'. Then run pip install. Verify with 'which python' (Linux) or 'where python' (Windows) that it points to the venv.
Why does insightface error out even after I install it?
insightface requires Microsoft Visual C++ Build Tools on Windows. Download them from visualstudio.microsoft.com (Build Tools for Visual Studio, 'Desktop development with C++' workload). Without this, C++ extension compilation fails even if pip shows no error.
What if two custom nodes need incompatible versions of a library?
This is a dependency conflict, common with transformers or numpy. Options: (1) install the newest version compatible with both, (2) use a separate virtual environment for the conflicting node, (3) report the conflict to the node's author on GitHub.
Share X LinkedIn

You may also like