38
votes

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?

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? - dogman288
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? - Hsarp
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.py - Hsarp

5 Answers

71
votes

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

13
votes

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
8
votes

This is what you need to do

wget https://bootstrap.pypa.io/2.7/get-pip.py
python get-pip.py
3
votes

Try installing previous version of get-pip

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

python get-pip.py

3
votes

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