Skip to content

Commit 5603226

Browse files
authored
fix: check pip module availability instead of PATH binary in download (#13947)
_get_pip_install_cmd() uses shutil.which("pip") to check for pip, then returns [sys.executable, "-m", "pip", "install"] which invokes pip as a module. The binary check fails in venvs where ensurepip creates pip3 but not pip (common on Debian/Ubuntu), even though python -m pip works. Replace shutil.which("pip") with importlib.util.find_spec("pip"), which tests the actual precondition: whether pip is importable in the current interpreter. The uv branch is unchanged since uv is a standalone binary. Fixes #13946
1 parent d4bb796 commit 5603226

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

spacy/cli/download.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib.util
12
import shutil
23
import sys
34
from typing import Optional, Sequence
@@ -189,7 +190,7 @@ def download_model(
189190

190191

191192
def _get_pip_install_cmd() -> list:
192-
if shutil.which("pip"):
193+
if importlib.util.find_spec("pip") is not None:
193194
return [sys.executable, "-m", "pip", "install"]
194195
elif shutil.which("uv"):
195196
return ["uv", "pip", "install"]

0 commit comments

Comments
 (0)