Skip to content

How to install `conda` to isolate the python package from your computer

MaraScott edited this page Sep 27, 2024 · 1 revision

Here's a simple step-by-step guide to install (mini)conda and use it to run ComfyUI :

Step 1: Download and Install Miniconda

  1. Go to the Miniconda download page: Miniconda Downloads.
  2. Choose your operating system: Select the correct installer for your system (Windows, macOS, or Linux).
    • For Windows: Download the .exe file.
    • For macOS: Download the .pkg file.
    • For Linux: Download the appropriate .sh file.
  3. Run the installer:
    • Windows: Double-click the .exe file and follow the prompts. Make sure to check the box that says "Add Miniconda to my PATH environment variable".
    • macOS/Linux: Open the terminal, navigate to the location of the .sh file, and run:
      bash Miniconda3-latest-Linux-x86_64.sh  # Adjust for the file name
      Follow the prompts to complete the installation.

Step 2: Open the Miniconda Terminal/Command Prompt

Once Miniconda is installed:

  • Windows: Open the Anaconda Prompt from the Start Menu.
  • macOS/Linux: Open your terminal.

Step 3: Create a New Environment

In the terminal, type the following to create a new Python environment (an isolated space for different versions of Python and libraries):

conda create --name ComfyUI python=3.11

Here, ComfyUI is the name of your environment, and python=3.11 installs Python version 3.11.

Step 4: Activate the Environment

After creating the environment, you need to activate it:

conda activate ComfyUI

If your conda env is activated you should see the name ComfyUI at the beginning of the CLI line like this :

# before
MaraScott_Cli>
# after
(ComfyUI) MaraScott_Cli>

Step 5: Run ComfyUI

You can now run ComfyUI which will automatically install all necessary Python libraries (e.g., numpy, requests).

If you use the portable version, you are use to execute run_nvidia_gpu.bat which contains the following code

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

I suggest to create a new file called run_nvidia_gpu_with_conda.bat with the following code

# conda activate ComfyUI
python -s ComfyUI\main.py --windows-standalone-build
pause

Only create this file for reminder but do not try to execute it by double-clicking it cause the conda env won't be activated, instead from your terminal with conda env activated execute this code :

(ComfyUI) MaraScott_Cli> python -s ComfyUI\main.py --windows-standalone-build

Step 7: Deactivate the Environment

When you're done, deactivate the environment by typing:

conda deactivate

That's it! You've successfully installed (mini)conda, created a Python environment, and run ComfyUI within its own conda env.