How To Upgrade Pip In Windows, MacOS & Linux
Users and developers of Python are probably familiar with PIP. It is the official package installer for Python and can be used to install packages that are not included with the standard Python distribution. You can use
pip to install packages that have been published in the official Python Package Index (PyPI) as well as other indexes.
Many users question exactly just how to upgrade to the latest version of PIP, given the ever-evolving and fast-moving python ecosystem. The short answer is,
pip is just like any other PyPI package and you can upgrade it to newer (or downgrade to older) versions, just as you would upgrade or downgrade any other package.
Related: How to install
pip on Windows, macOS & Linux
# Windows Command Prompt > python -m pip install --upgrade pip # Linux Terminal $ pip install --upgrade pip # MacOS Terminal $ pip install --upgrade pip
How To Update Your Version Of Pip In Windows
On Windows, you can upgrade pip by opening the Command Prompt, and typing the following command:
python -m pip install --upgrade pip
An important thing to note is that this command will only work if you have successfully managed to add Python to Windows path. If you haven't done so, you might get the following error in your command prompt:
> ‘pip’ is not recognized as an internal > or external command, operable program or batch file
If this error does occur, you must first add Python to Windows path and then update your PIP version.
Upgrade Or Downgrade Pip To A Specific Version on Windows
If you want to upgrade or downgrade Pip to an exact version, there is a way to do that. If you know which version you want, just add a flag:
pip==<version> to the command above.
For example, if you want to downgrade to version 19.2, the final command would look something like this,
> python -m pip install pip==19.2
How To Update Your Version Of Pip In Linux
The process of updating
pip in Linux is pretty straightforward. The first thing you need to do is to check your version of pip typing the following command:
$ pip --version
Once you know your current version and you are sure that you want to upgrade, you can use the pip install upgrade command in the terminal and hit enter.
$ pip install -U pip or $ pip install --upgrade pip
This will upgrade your pip version to the latest.
If you run into permission issues, you may also try the following commands. When you use
sudo you might also have to enter your root password.
$ sudo -H pip3 install --upgrade pip $ sudo -H pip2 install --upgrade pip
How To Update Your Version Of Pip In MacOS
The command to upgrade PIP on MacOS is the same as in Linux.
$ pip install --upgrade pip
If you get an error:
pip command not found, you can instead use the following command:
$ python -m pip install --upgrade pip
Note, these commands also work for pip3. Moreover, if you have pip3 installed, you can use the pip3 alias and it will work the same way.
$ pip3 install --upgrade pip
Upgrade Or Downgrade To Specific Pip Version
If you want to upgrade or downgrade your version of pip to a specific version on a Mac, you can do this by adding a
pip==<version> flag to the end of your update command.
$ pip3 install --upgrade pip==20.2.2 or $ pip install --upgrade pip==20.2.2
When using Python, it is important to make sure to keep your dependencies up to date, and this goes for versions of
pip as well. This guide will make sure that you are always on the right version no matter what your operating system is.