pip install failing on python2 [duplicate]
Asked Answered
P

5

45

Following the instructions on this page to install pip on python2 https://linuxhint.com/installing_pip_linux_mint/

It's failing at the last step, $ sudo python2 get-pip.py

with this error,

Traceback (most recent call last):
  File "get-pip.py", line 24226, in <module>
    main()
  File "get-pip.py", line 199, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    from pip._internal.cli.main import main as pip_entry_point
  File "/tmp/tmp2aZyDl/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

I've tried to look everywhere for a solution, but can't find one. What is it that I'm doing wrong?

Permeable answered 24/1, 2021 at 1:47 Comment(5)
The f"some string {some_variable}" is Python 3.6+ syntax, are you sure you're using the right get-pip.py for Python 2?Homesteader
I'm not sure if I'm using the right get-pip.py. According to the instructions on the webpage, I added the universe repository, ran apt update, installed python2, which I already had, and ran this command $ curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py, followed by $ sudo python2 get-pip.py. Maybe the get-pip has been overwritten by the file required for Python3?Permeable
They really need to update the instructions. The right file for python2 has been moved over to here, https://bootstrap.pypa.io/2.7/get-pip.pyPermeable
See https://mcmap.net/q/94705/-installing-pip-is-not-working-in-python-lt-3-6Fluctuation
Does this answer your question? Python Pip broken wiith sys.stderr.write(f"ERROR: {exc}")Hach
P
84

The correct get-pip.py file for python2 has been moved to https://bootstrap.pypa.io/pip/2.7/get-pip.py

Permeable answered 24/1, 2021 at 2:11 Comment(2)
is there a way to update this to install python via pyenv install py2.7.1.1Billiot
The new downloading location is correct but it gives the following error during the installation curl bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1863k 100 1863k 0 0 2637k 0 --:--:-- --:--:-- --:--:-- 2635k root@c0010-10213595-1:~# python get-pip.py ERROR: Could not find a version that satisfies the requirement pip<21.0 (from versions: none) ERROR: No matching distribution found for pip<21.0Melainemelamed
O
17

PIP has dropped support for Python 2.7 in the result you are facing the above issue, so the only thing is to downgrade the version of pip.

only the following command worked for me...

sudo easy_install pip==20.3.4
Olnee answered 8/2, 2021 at 20:5 Comment(2)
This is the only solution that worked for me. Thank you.Verminous
Thank you this worked for me. After 30 mins of searchingGrenade
M
10

This is what you need to do

wget https://bootstrap.pypa.io/2.7/get-pip.py
python get-pip.py
Michele answered 26/1, 2021 at 16:43 Comment(1)
bootstrap.pypa.io/pip/2.7/get-pip.py is the right URLSkinnydip
R
4

I was getting this error with pip. This command worked for me sudo easy_install pip==20.3.4

Rasbora answered 11/2, 2021 at 0:59 Comment(0)
S
3

Try installing previous version of get-pip

wget https://bootstrap.pypa.io/3.5/get-pip.py

python get-pip.py

Sassafras answered 25/1, 2021 at 9:56 Comment(1)
Can Confirm this works in 2021 on Kali Linux 20.04 :)Schroth

© 2022 - 2024 — McMap. All rights reserved.