Globally installed comfy-cli does not respect activated venv
Describe the bug I installed comfy-cli globally (outside any venv) and activated a local conda venv
conda activate .\venv\
comfy cli does not work when called.
examples :
comfy node save-snapshot
Execute from: D:\AI\ComfyUI
Execution error: ['C:\\AI\\python.exe',
'D:\\AI\\ComfyUI\\custom_nodes\\ComfyUI-Manager\\cm-cli.py', 'save-snapshot']
python D:\AI\ComfyUI\custom_nodes\ComfyUI-Manager\cm-cli.py save-snapshot
WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI
path.
[ComfyUI-Manager] The ComfyRegistry cache update is still in progress, so an outdated cache is being used.
FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json [DONE]
Current snapshot is saved as `2025-05-17_13-05-33_snapshot.json`
comfy launch
Launching ComfyUI from: D:\AI\ComfyUI
Adding extra search path checkpoints stuff here
Failed to execute startup-script: D:\AI\ComfyUI\custom_nodes\ComfyUI-Manager\prestartup_script.py / No module named 'huggingface_hub'
Prestartup times for custom nodes:
0.0 seconds: D:\AI\ComfyUI\custom_nodes\rgthree-comfy
0.0 seconds: D:\AI\ComfyUI\custom_nodes\comfyui-easy-use
1.4 seconds (PRESTARTUP FAILED): D:\AI\ComfyUI\custom_nodes\ComfyUI-Manager
Traceback (most recent call last):
File "D:\AI\ComfyUI\main.py", line 128, in <module>
import comfy.utils
File "D:\AI\ComfyUI\comfy\utils.py", line 20, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
To Reproduce Create a local conda env
conda create -p ./venv python=3.11
Install comfy-cli globally (outside the env)
pip install comfy-cli
Activate the local conda env
conda activate ./venv
Run any comfy-cli command that wraps internal scripts:
comfy node save-snapshot
It fails silently or errors out.
The subprocess is spawned with the global Python (not the active conda env), so we get dependencies failure
Running the same commands directly through python inside the env works as expected:
python custom_nodes/ComfyUI-Manager/cm-cli.py save-snapshot
Expected behavior The comfy CLI does not detect or honor the active conda environment, it should
Additional context Should have been fixed in #75 but its not for me
Installing it inside the conda venv works straight out of the box
pip uninstall comfy-cli
...
Successfully uninstalled comfy-cli-1.3.9
conda activate .\venv\
pip install comfy-cli
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting comfy-cli
Downloading comfy_cli-1.3.9-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: charset-normalizer>=3.0.0 in e:\ai\_comfyui\311\comfyui\venv\lib\site-packages (from comfy-cli) (3.4.1)
...
comfy node save-snapshot
Execute from: D:\AI\ComfyUI
[ComfyUI-Manager] The ComfyRegistry cache update is still in progress, so an outdated cache is being used.
FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json [DONE]
Current snapshot is saved as `2025-05-17_13-19-08_snapshot.json
I am using Windows 11
Hello @zdaar! I'm Dosu, a friendly bot here to help you with bugs, answer your questions, and assist you in becoming a contributor. I'm ready to assist while you wait for a human maintainer. Let's tackle your issue together!
The issue you're experiencing is due to comfy-cli using sys.executable to determine the Python interpreter for executing commands. This means it defaults to the Python interpreter that was used to install comfy-cli, which in your case is the global Python environment, not the activated conda environment [1].
To resolve this, you can either:
-
Install
comfy-cliwithin the conda environment: This ensures that the correct Python interpreter from the activated environment is used, as you've already discovered. -
Modify the PATH: Ensure that the conda environment's Python interpreter is first in your PATH when executing
comfy-clicommands. This might involve adjusting your environment variables or using a wrapper script to callcomfy-cliwith the correct Python interpreter. -
Use a virtual environment-specific command: Instead of using the globally installed
comfy-cli, you can directly call the script using the Python interpreter from the activated conda environment, as you've done withpython custom_nodes/ComfyUI-Manager/cm-cli.py save-snapshot.
These approaches should help comfy-cli respect the activated conda environment and use its Python interpreter, resolving the dependency issues you're facing.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
Seems to be same root cause as #263