Solving Python PIP Install TypeError: unsupported operand type(s) for -=: ‘Retry’ and ‘int’

TypeError: unsupported operand type(s) for -=: ‘Retry’ and ‘int’ is an error which happens in Python you are dealing with a faulty pip installation.

In this article I am going to explain why the error is occurring and how to solve it using multiple solutions which may work for your particular case.

Explaining the Error : TypeError: unsupported operand type(s) for -=: ‘Retry’ and ‘int’

The error can happen to anyone trying to install pip. There are many reasons why the error could be happening and there are many solutions. We will be covering both in the sections bellow.

Bellow is an extract of the error message. Your error message should be similar.

                                                                       #
~$ pip install requests
Collecting requests
Exception:
Traceback (most recent call last):
    status = self.run(options, args)
....
    _stacktrace=sys.exc_info()[2])
    total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
                                                                       #

Bellow I make my best attempt at solving the error and present multiple possible solutions.

Solution 1 : only for ubuntu users

The first solution is to follow these instructions step by step.

First, start by running the command bellow in order to remove python from your machine.

                                                                       #
apt-get remove python-pip python3-pip
                                                                       #

use wget to get pip

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

Run the command bellow.

                                                                       #
python get-pip.py
                                                                       #

Finally, run the following command.

                                                                       #
python3 get-pip.py
                                                                       #

If this solution has fixed your issue, congratulations.

If it has not then try the next solution, you never know. This might be the one.

Solution 2 : Update setuptools

If the solution above did not work. Try updating setuptools.

Run the following command in order to do that.

                                                                       #
sudo pip install --upgrade setuptools
                                                                       #

The solutions above should be enough to solve the problem, if you like our effort make sure to consider donating to our Kofi account, there is a red button that you can use if you are feeling generous.

Summing-up

This is the end of our article, I hope one of the above solutions was enough to solve the issue, make sure to keep learning and keep coding, Python is awesome and it is a skill worth learning, cheers.

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