Skip to content

fix: check pip module availability instead of PATH binary in download#13947

Merged
honnibal merged 1 commit intoexplosion:masterfrom
taylorsatula:fix/download-pip-module-check
Mar 28, 2026
Merged

fix: check pip module availability instead of PATH binary in download#13947
honnibal merged 1 commit intoexplosion:masterfrom
taylorsatula:fix/download-pip-module-check

Conversation

@taylorsatula
Copy link
Copy Markdown
Contributor

Fixes #13946.

_get_pip_install_cmd() checks shutil.which("pip") then returns [sys.executable, "-m", "pip", "install"]. The binary check and the module invocation test different things. In venvs where ensurepip creates pip3 but not bare pip (standard on Debian/Ubuntu), the binary check fails even though python -m pip works.

Replaces shutil.which("pip") with importlib.util.find_spec("pip") — the actual precondition for sys.executable -m pip. The uv branch is unchanged since uv is a standalone binary where shutil.which is the right check.

No new dependencies (stdlib). No change in behavior for environments where both pip and pip3 exist.

_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 explosion#13946
@honnibal honnibal merged commit 5603226 into explosion:master Mar 28, 2026
@honnibal
Copy link
Copy Markdown
Member

Thanks! I should've paid more attention on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spacy download fails in venvs with pip3 but no pip binary (regression in 3.8.12)

2 participants