Skip to content
Home » get-pip.py returns SyntaxError: invalid syntax

get-pip.py returns SyntaxError: invalid syntax

To solve get-pip.py returns SyntaxError: invalid syntax error follow below methods.

ERROR LOG

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

How to solve get-pip.py returns SyntaxError: invalid syntax ?

Python 2.7 support is deprecated in recent versions of pip, which is why you’re seeing this issue.

To keep your sanity with Python 2.7 with pip, either downgrade to a lower version of pip or use 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

Alternative to Solve get-pip.py returns SyntaxError: invalid syntax

As a result of PIP dropping support for Python 2.7, you are experiencing the aforementioned issue, and the only solution is to downgrade the version of pip.

pip install --upgrade pip==20.3

Hope the above solution works.

Also read :

The Python path in your debug configuration is invalid
pip install failing on python2