-
Notifications
You must be signed in to change notification settings - Fork 85
Description
Describe the Bug
Currently, comfy-cli
attempts to install dependencies into the environment it is running in. This can lead to incorrect behavior when comfy-cli
is installed in a different (virtual) environment than ComfyUI. This situation often occurs when using Python application managers like pipx
or uv tool
, which isolate CLI tools in their own environments.
To Reproduce
-
Ensure you have a Python application management tool installed (e.g.,
uv tool
). -
Install
comfy-cli
usinguv
:uv tool install comfy-cli
This creates a dedicated environment for
comfy-cli
. -
Clone ComfyUI:
git clone [email protected]:comfyanonymous/ComfyUI.git
-
Create and activate a virtual environment for ComfyUI:
python3 -m venv comfy-env source ./comfy-env/bin/activate
-
Run
comfy install --restore
.
Observed behavior:
Installation fails, complaining that pip
is not available. The error indicates that it's trying to use the Python interpreter from the uv
environment rather than the currently activated virtual environment.
- You want to apply the workaround suggested in Comfy Install fails - Pytorch dependencies #245 and run
ensurepip
for that Python. Although this fixes the issue itself, the logs would show that dependencies are installed into thecomfy-cli
environment, which is not the intended behavior.
Expected Behavior
comfy-cli
should install dependencies into the virtual environment associated with ComfyUI, or at least respect the currently activated environment.
Nice to Have
- Terminal output
- Screenshots
Additional Context
In comfy_cli/command/install.py
, sys.executable
is used to determine the Python interpreter for pip install
. However, this always resolves to the environment in which comfy-cli
itself is running—not necessarily the one ComfyUI is intended to use.
A more robust approach might be to resolve python
or pip
via:
python_path = shutil.which("python", path=os.environ.get("PATH", ""))
pip_path = shutil.which("pip", path=os.environ.get("PATH", ""))
This would respect the user's shell environment and active virtualenv (or other environments like conda), aligning the install target more accurately.