get-pip.py returns SyntaxError: invalid syntax [duplicate]

I installed pip from this command

curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py

and when I did sudo python2 get-pip.py

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/tmpf3jeCG/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

It was working fine a few weeks back and then suddenly it has stopped working. I really need to know what I have done wrong? Is there any other way I can do it? I'm using Atlassian Bitbucket which has Java8 image. I also need pip installed since I can not have more than one image. I'm downloading it locally using the above command and making pip work. Is there anyother way I can use it to make it work?


The support for Python 2.7 is deprecated on newer versions of pip, hence the reason why you're noticing this error here.

In order for you to maintain the sanity with Python 2.7 and pip, either maintain yourself to lower version of pip using the pip installer itself

pip install --upgrade pip==20.3

or make use of the Python 2.7 specific version of get-pip.py

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py