11

After installing succesfully python2 on ubuntu 20.04 with: sudo apt install python2

I downloaded get-pip.py from https://bootstrap.pypa.io/get-pip.py sha256: ffb67da2e976f48dd29714fc64812d1ac419eb7d48079737166dd95640d1debd

Running:

sudo python2 get-pip.py

Traceback (most recent call last):
File "get-pip.py", line 24226, in
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/tmp6DHWFv/pip.zip/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax

godot
  • 3,422
  • 6
  • 25
  • 42
Juan A. Muñoz
  • 171
  • 1
  • 1
  • 5
  • Python2 does not support f-string and f"ERROR: {exc}" is a f-string. Thus, this get-pip.py is for Python3 – sinkmanu Jan 24 '21 at 10:23
  • Slightly off topic, but want to mention: in many cases, a virtualenv ( https://docs.python.org/3/library/venv.html ) is a good solution for using other python versions than the system-wide version. – mfit Jan 24 '21 at 10:33
  • See https://stackoverflow.com/a/65871131/7976758 – phd Jan 24 '21 at 13:44

4 Answers4

19

you can use this commands. It's working right now. You have to install with Python2

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2 get-pip.py
ritimsiz
  • 191
  • 3
6

This version seems not working, so I downloaded a previos version from:
https://bootstrap.pypa.io/2.6/get-pip.py. After running the following command:

sudo python2 get-pip.py

pip version 9.0.3 was installed. Following a

sudo pip install --upgrade pip

pip 20.3.4 was installed. Enough to run the python tools I need.

Juan A. Muñoz
  • 171
  • 1
  • 1
  • 5
4

I will post an updated answer here. Pip authors updated the link and asked for apologies.

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2 get-pip.py
red
  • 634
  • 1
  • 6
  • 12
0

This is a very old post, but it's the first thing that appeared when I googled for ubuntu how to install pip2 - I use python3 and whilst I do have a python2, it's bare-bones.

For the first time, I'm having to use equivelent of pip for python2. Following the OP provided URL, and then running it with python2.7 get-pip.py I found it gives me the answer in its output! It tells you get get [this script at https://bootstrap.pypa.io/pip/2.7/get-pip.py] (https://bootstrap.pypa.io/pip/2.7/get-pip.py) and use that instead. I don't know if that is new, since this post is dated last year, but I thought it was well worth providing an updated answer:

    noscere@bertram:~$ wget https://bootstrap.pypa.io/get-pip.py
    noscere@bertram:~$ chmod +x get-pip.py
    noscere@bertram:~$ python2.7 ~/bin/get-pip.py
    ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.7. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
    noscere@bertram:~$ mv get-pip.py ~/bin/get-pip3.py
    noscere@bertram:~/src/ubuntu-tweak$ wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
    noscere@bertram:~$ chmod +x get-pip.py
    noscere@bertram:~$ python2.7 get-pip.py
    DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020.
    Please upgrade your Python as Python 2.7 is no longer maintained.
    pip 21.0 will drop support for Python 2.7 in January 2021. More
    details about Python 2 support in pip can be found at 
    https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
    Collecting pip<21.0
      Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
         |████████████████████████████████| 1.5 MB 146 kB/s 
    Collecting wheel
      Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
    Installing collected packages: pip, wheel
    Successfully installed pip-20.3.4 wheel-0.37.1
Noscere
  • 417
  • 3
  • 8