Actually filter out missing interpreters (#5262)

* Actually filter out missing interpreters

This fixes https://github.com/pypa/pipenv/issues/5261.

Before this change, I would get a "The Python interpreter can't be
found" error when running `pipenv install --system` with a python3 but
no python.
This commit is contained in:
Jeremy Fleischman
2022-08-16 12:33:34 -07:00
committed by GitHub
parent f73a5ae407
commit 77bc74dce5
4 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ How does this pull request fix your problem? Did you consider any alternatives?
### The checklist
* [ ] Associated issue
* [ ] A news fragment in the `news/` directory to describe this fix with the extension `.bugfix`, `.feature`, `.behavior`, `.doc`. `.vendor`. or `.trivial` (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.
* [ ] A news fragment in the `news/` directory to describe this fix with the extension `.bugfix.rst`, `.feature.rst`, `.behavior.rst`, `.doc.rst`. `.vendor.rst`. or `.trivial.rst` (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.
<!--
### If this is a patch to the `vendor` directory...
+1 -1
View File
@@ -56,7 +56,7 @@ Or, if you\'re using FreeBSD:
Or, if you\'re using Gentoo:
sudo emerge pipenv
Or, if you\'re using Void Linux:
sudo xbps-install -S python3-pipenv
+1
View File
@@ -0,0 +1 @@
Fix "The Python interpreter can't be found" error when running ``pipenv install --system`` with a python3 but no python.
+1
View File
@@ -446,6 +446,7 @@ def project_python(project, system=False):
python = project._which("python")
else:
interpreters = [system_which(p) for p in ("python", "python3")]
interpreters = [i for i in interpreters if i] # filter out not found interpreters
python = interpreters[0] if interpreters else None
if not python:
click.secho("The Python interpreter can't be found.", fg="red", err=True)