pipenv install --system fails when `python` points to Python 2.
See original GitHub issueIssue description
Since 2022.8.15 pipenv install --system
will fail on systems that have both Python 2 and Python 3 installed but which python
resolves to Python 2. In commit dbea3f5 it switched from using project._which()
which uses sys.executable
to determine which python to run to using python_project()
which, when using --system
first checks for python
and then python3
. So if, e.g. your project/system is using Python 3 which is installed as /usr/local/bin/python3
but your system Python package us Python 2 which is at /usr/bin/python
then it will try to execute using Python 2, resulting in
[pipenv.exceptions.InstallError]: File "/git-test/pipenv/patched/pip/__pip-runner__.py", line 21
[pipenv.exceptions.InstallError]: fullname: str,
[pipenv.exceptions.InstallError]: ^
[pipenv.exceptions.InstallError]: SyntaxError: invalid syntax
Expected result
Expected result is pipenv install --system
installs the dependencies using Python 3. Although Iβm not sure itβs really a bug since technically it is using the βsystemβ Python. Nevertheless it is a regression.
Actual result
# python3 -m pipenv install --system --verbose
Installing dependencies from Pipfile.lock (89d195)...
Writing supplied requirement line to temporary file: "dataclasses==0.8; python_version < '3.7' --hash=sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97 --hash=sha256:0201d89fa866f68c8ebd9d08ee6ff50c0b255f8ec63a71c16fda7af82bb887bf"
Installing 'dataclasses'
$ /usr/bin/python /usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py install --verbose --upgrade --require-hashes --no-deps --exists-action=i -r /tmp/pipenv-v0jrsbzs-requirements/pipenv-_x_y9mvb-requirement.txt
Writing supplied requirement line to temporary file: "importlib-metadata==4.8.2; python_version < '3.8' --hash=sha256:53ccfd5c134223e497627b9815d5030edf77d2ed573922f7a0b8f8bb81a1c100 --hash=sha256:75bdec14c397f528724c1bfd9709d660b33a4d2e77387a3358f20b848bb5e5fb"
Installing 'importlib-metadata'
$ /usr/bin/python /usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py install --verbose --upgrade --require-hashes --no-deps --exists-action=i -r /tmp/pipenv-v0jrsbzs-requirements/pipenv-y_uqgaka-requirement.txt
Writing supplied requirement line to temporary file: "typing-extensions==4.0.1; python_version < '3.8' --hash=sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b --hash=sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"
Installing 'typing-extensions'
$ /usr/bin/python /usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py install --verbose --upgrade --require-hashes --no-deps --exists-action=i -r /tmp/pipenv-v0jrsbzs-requirements/pipenv-k8di4opm-requirement.txt
π ββββββββββββββββββββββββββββββββ 3/3 β 00:00:00
File "/usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py", line 21
fullname: str,
^
SyntaxError: invalid syntax
An error occurred while installing dataclasses==0.8; python_version < '3.7' --hash=sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97 --hash=sha256:0201d89fa866f68c8ebd9d08ee6ff50c0b255f8ec63a71c16fda7af82bb887bf! Will try again.
File "/usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py", line 21
fullname: str,
^
SyntaxError: invalid syntax
An error occurred while installing importlib-metadata==4.8.2; python_version < '3.8' --hash=sha256:53ccfd5c134223e497627b9815d5030edf77d2ed573922f7a0b8f8bb81a1c100 --hash=sha256:75bdec14c397f528724c1bfd9709d660b33a4d2e77387a3358f20b848bb5e5fb! Will try again.
File "/usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py", line 21
fullname: str,
^
SyntaxError: invalid syntax
An error occurred while installing typing-extensions==4.0.1; python_version < '3.8' --hash=sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b --hash=sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e! Will try again.
Installing initially failed dependencies...
Writing supplied requirement line to temporary file: "dataclasses==0.8; python_version < '3.7' --hash=sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97 --hash=sha256:0201d89fa866f68c8ebd9d08ee6ff50c0b255f8ec63a71c16fda7af82bb887bf"
Installing 'dataclasses'
$ /usr/bin/python /usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py install --verbose --upgrade --require-hashes --no-use-pep517 --no-deps --exists-action=i -r /tmp/pipenv-v0jrsbzs-requirements/pipenv-x1ek7nrg-requirement.txt
Writing supplied requirement line to temporary file: "importlib-metadata==4.8.2; python_version < '3.8' --hash=sha256:53ccfd5c134223e497627b9815d5030edf77d2ed573922f7a0b8f8bb81a1c100 --hash=sha256:75bdec14c397f528724c1bfd9709d660b33a4d2e77387a3358f20b848bb5e5fb"
Installing 'importlib-metadata'
$ /usr/bin/python /usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py install --verbose --upgrade --require-hashes --no-use-pep517 --no-deps --exists-action=i -r /tmp/pipenv-v0jrsbzs-requirements/pipenv-iyfa0tgp-requirement.txt
Writing supplied requirement line to temporary file: "typing-extensions==4.0.1; python_version < '3.8' --hash=sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b --hash=sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"
Installing 'typing-extensions'
$ /usr/bin/python /usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py install --verbose --upgrade --require-hashes --no-use-pep517 --no-deps --exists-action=i -r /tmp/pipenv-v0jrsbzs-requirements/pipenv-jmqhat8h-requirement.txt
File "/usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py", line 21
fullname: str,
^
SyntaxError: invalid syntax
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.9/site-packages/pipenv/patched/pip/__pip-runner__.py", line 21
[pipenv.exceptions.InstallError]: fullname: str,
[pipenv.exceptions.InstallError]: ^
[pipenv.exceptions.InstallError]: SyntaxError: invalid syntax
ERROR: Couldn't install package: dataclasses
Package installation failed...
/usr/local/lib/python3.9/subprocess.py:1052: ResourceWarning: subprocess 742 is still running
_warn("subprocess %s is still running" % self.pid,
ResourceWarning: Enable tracemalloc to get the object allocation traceback
sys:1: ResourceWarning: unclosed file <_io.FileIO name=6 mode='rb' closefd=True>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
sys:1: ResourceWarning: unclosed file <_io.FileIO name=9 mode='rb' closefd=True>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
β€ ββββββββββββββββββββββββββββββββ 2/3 β 00:00:00
/usr/local/lib/python3.9/subprocess.py:1052: ResourceWarning: subprocess 741 is still running
_warn("subprocess %s is still running" % self.pid,
ResourceWarning: Enable tracemalloc to get the object allocation traceback
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 encoding='utf-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=7 encoding='utf-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
Steps to replicate
- Prepare a container, e.g. a CentOS container that has Python 2.7 as the system python.
- Install Python 3 into
/usr/local
but ensure there is no/usr/local/bin/python
- Create a simple Pipfile then
pipenv install --system
Please run $ pipenv --support
, and paste the results here. Donβt put backticks (`
) around it! The output already contains Markdown formatting.
I can not paste the actual output but please let me know if you still need it and I will try to come up with a trivial reproducer.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
I havenβt tried to see if this breaks anything else, but this simple change worked for me:
pipenv, version 2022.8.30 has been released.