Tutorial for installing ComfyUI on macOS

Ying Li
5 min readJun 1, 2024

--

This article will let you learn how to install and successfully run ComfyUI on macOS. It is very beginner friendly and all the steps I will explain in easy to understand language.

Step 1 Open Terminal

Hold down Command + Space, input Terminal, Enter to confirm the entry.

Step 2 Install Xcode

Copy the code below to Terminal, run it, keep the network open, and wait for the automatic installation to complete.

xcode-select --install

Step 3 Install Homebrew

Copy the code below to Terminal, run it, keep the network open, and wait for the automatic installation to complete.

Homebrew official website address https://brew.sh

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 4 Install Python

Copy the code below to Terminal, run it, keep the network open, and wait for the automatic installation to complete.

brew install python3

Step 5 Install Git

Copy the code below to Terminal, run it, keep the network open, and wait for the automatic installation to complete.

brew install git

Step 6 Check Python and Git Versions

Copy the following code in order to Terminal, Enter to run.

python3 --version
pip3 --version
git --version

If everything installed correctly, you should see the version displayed normally as shown below.

Step 7 Install ComfyUI

Copy the code below to Terminal, run it, keep the network open, and wait for the automatic installation to complete.

git clone https://github.com/comfyanonymous/ComfyUI

If you have already installed ComfyUI, it will appear as shown below, if the subsequent steps have reported an error and can not find a solution, it is recommended to delete the entire ComfyUI folder and start again from this step.

Step 8 Install the virtual environment

This is important, without the virtual environment subsequent steps can not be advanced properly.

Copy the following code in order to Terminal, run it, and go into the ComfyUI folder.

cd ComfyUI

Type pwd and run it to see your current folder directory. At this point you should be in the /Users/your username/ComfyUI path.
Next, Create a virtual environment for Python.

python3 -m venv venv

Activate the virtual environment.

source venv/bin/activate

If all went well, you should see the following image. (venv) means that you have successfully entered the virtual environment.

By the way, how to turn off a virtual environment.

Type deactivate, run it, and the (venv) prefix disappears to represent that the virtual environment has been exited.

Step 9 Install Pytorch Nightly Build

Copy the following code to the Terminal, run it, keep the network open, wait for the automatic installation is complete. Must install nightly build version, can not install the version of the official website, otherwise the follow-up will report errors.

pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu

Step 10 Download the AI model and place it

Here we take the download of SDXL Turbo model as an example.

SDXL Turbo model download address https://huggingface.co/stabilityai/sdxl-turbo/tree/main

Go to the web site, click on the markings in the picture below and click on download.

After the model file are downloaded, hold down Command + Space and type checkpoints to select the first folder to enter.

Drag and drop the SDXL Turbo model file from the download folder into the checkpoints folder to finish.

Note that it is the checkpoints folder, not the _checkpoint folder.

Step 11 Install ComfyUI Manager

Type pwd, run it, and make sure your current path is under ComfyUI.

Copy the code below to [Terminal], [Enter] to run it, and enter the [custom_nodes] folder.

Copy the code below to Terminal, run it, and enter the [custom_nodes] folder.

cd custom_nodes

Copy the code below to Terminal, run it, keep the network open, and wait for the automatic installation to complete.

git clone https://github.com/ltdrdata/ComfyUI-Manager

If all goes well, then as shown below.

Step 12 Install Python dependencies

Copy the code below to Terminal, run it, and return to the parent directory.

cd ..

Copy the code below to Terminal, run it, keep the network open, and wait for the automatic installation to complete.

pip install -r requirements.txt

Step 13 Launch ComfyUI

First you need to make sure you are currently under the /ComfyUI path. You can check this by typing and run pwd.

Copy the code below to Terminal and run it.

python main.py --force-fp16

The URL http://127.0.0.1:8188 shown in the following figure appears, which means you have successfully launched, copy the address and paste it into your browser to open it.

As shown in the picture, congratulations on successfully entering the Comfy UI interface.

Possible errors and solutions

ModuleNotFoundError: No module named ‘distutils’

This means that your Python environment is missing the distutils module, which is typically used to package and install other modules and packages.

Solutions and Steps

Step 1 Activate the virtual environment

source /Users/liying/ComfyUI/venv/bin/activate

Copy the code to the terminal and run it, (venv) appears for success, as shown in the figure.

Step 2 Install setuptools

In Python 3.12 and later, the distutils module has been removed and setuptools is recommended. you can install setuptools to fix this.

pip install setuptools

Step 3 Install torch

You need to make sure that torch is installed in your virtual environment, if not please run it.

pip install torch

Step 4 Updating all the dependencies

Sometimes compatibility issues between dependencies can cause similar errors. You can try updating all the dependencies.

pip install --upgrade setuptools pip

Step 5 Run your program again

python main.py --force-fp16

If the above steps do not solve the problem, make sure that the requirements.txt file in your ComfyUI project folder is up-to-date and reinstall all dependencies in your virtual environment.

pip install -r /Users/liying/ComfyUI/requirements.txt

This should solve the problem of the missing distutils module.

--

--