Skip to content

pip upgrade inside python 2.7 environment breaks pip #9724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
securestep9 opened this issue Mar 22, 2021 · 2 comments
Closed
1 task done

pip upgrade inside python 2.7 environment breaks pip #9724

securestep9 opened this issue Mar 22, 2021 · 2 comments
Labels
resolution: duplicate Duplicate of an existing issue/PR

Comments

@securestep9
Copy link

pip version

19.1

Python version

2.7

OS

RHEL 7.9

Additional information

No response

Description

in pip2.7 environment (yes, I know people still use Python2 as there are 1000s of systems not yet supporting python3) running a pip install --upgrade pip install version 21.1.0 which broke itself (pip2) with error:

File "/usr/bin/pip", line 9, in
load_entry_point('pip==21.0.1', 'console_scripts', 'pip2')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax

Expected behavior

pip upgrade should detect that it is running in python 2.x environment an should refuse to upgrade itself beyond v.20.x

How to Reproduce

inside python 2.7 environment run:

pip install --upgrade pip

now try to run pip - get error:

Output

pip install --upgrade pip
 File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==21.0.1', 'console_scripts', 'pip2')()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@securestep9 securestep9 added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Mar 22, 2021
@securestep9 securestep9 changed the title pip upgrade inside python 2.7 environment brakes pip pip upgrade inside python 2.7 environment breaks pip Mar 22, 2021
@pfmoore
Copy link
Member

pfmoore commented Mar 22, 2021

I suspect (you don't mention the version you're upgrading from) that the version of pip you're installing from doesn't support the Requires-Python metadata that addresses this issue. So you'll have to explicitly restrict the version you're upgrading to.

The good news is that once you've upgraded, the new pip will be able to detect that newer versions don't support Python 2.7, and so will not fail in this way in future...

@uranusjr
Copy link
Member

See discussion in #9526.

@uranusjr uranusjr added resolution: duplicate Duplicate of an existing issue/PR and removed S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Mar 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate Duplicate of an existing issue/PR
Projects
None yet
Development

No branches or pull requests

3 participants