Solve – Installing pip is not working in python < 3.6

Installing pip is not working in python is an error that only occurs in Python versions prior to Python 3.6.

In this article we will explore the root of this error, why is the error occurring in the first place and how to solve it, I am also going to share other solutions which worked for other developers.

Describing : Installing pip is not working in python

First let us try to duplicate the error step by step :

Let’s start with this line of code

                                                                       #
apt-get update
                                                                       #

Then let us run this line

                                                                       #
apt-get install -y python-dev
                                                                       #

Followed with

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

Then the problematic line that will cause the error

                                                                       #
python get-pip.py
                                                                       #

The error will look like this

                                                                       #
  File "get-pip.py", line 24226, in &lt;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/tmpUgc5ng/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax
                                                                       #

Solution 1 : reinstall the current version of pip using –upgrade

The solution is to reinstall the current version of pip, Let us start with this command

                                                                       #
python -m pip install --upgrade "pip &lt; 19.2"
                                                                       #

Then let us run the following command

                                                                       #
python -m pip install --upgrade "pip &lt; 21.0".
                                                                       #

The error should be gone by now, if it persists the solutions bellow may work instead.

Solution 2 : download and install the old get-pip

Another solution is to download the old get-pip and install it.

To download it let us run the following command

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

Now let us install get-pip with the following command

                                                                       #
python get-pip.py
                                                                       #

This should have solved the error, if it did not solve it consider giving the solutions bellow a shot.

Solution 3 : try python get-pip.py

To install pip for versions of Python bellow 3.6, first let us get it using the command bellow from the correct URL

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

Let us follow it by the command bellow

                                                                       #
python get-pip.py
                                                                       #

Let us use this last command in order to upgrade to the latest supported version

                                                                       #
python -m pip install --upgrade "pip &lt; 21.0"
                                                                       #

I hope this solution worked for you, please consider supporting the blog by clicking on the red Kofi button at the top of this page.

Summing-up

This is the end of our article, I hope the solutions I presented worked for you, Learning Python is a fun journey, do not let the errors discourage you. Keep coding and cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/