Skip to content

Commit

Permalink
Actually filter out missing interpreters
Browse files Browse the repository at this point in the history
This fixes pypa#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.

Demo:

```
$ docker run $(docker build -q -f Dockerfile.pipenv-2022.8.15 https://github.com/jfly/2022-08-16-pipenv-system-which-issue.git#main)
Installing dependencies from Pipfile.lock (63bec0)...
The Python interpreter can't be found.▉ 0/4 — 00:00:00
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/4 — 00:00:00
```

I'm confident this bug was introduced in
pypa@f276360,
which removed a usage of `first()`, but broke the "filter None values"
behavior that `first()` gave us.
  • Loading branch information
jfly committed Aug 16, 2022
1 parent f73a5ae commit 768aca0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pipenv/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 768aca0

Please sign in to comment.