You can upgrade the Python pip package installer to the newest(latest) available version or to a specific version using the pip command itself. Yes, you have read it right, you can use the pip command to upgrade itself.
Python pip is a package manager that is used to install and uninstall third-party packages that are not part of the Python standard library. Using pip you can install/uninstall/upgrade/downgrade any python library that is part of Python Package Index.
pip is a PyPI package like any other package in python hence you can use pip command to upgrade its version. for example, upgrade Pandas Version to the new version available.
1. Get Current pip Version
Before you upgrade, first let’s get the current pip version by running
(base) C:\Users\sai>pip --version pip 18.1 from C:\ProgramData\Anaconda3\lib\site-packages\pip (python 3.7) (base) C:\Users\sai>
2. Upgrade pip to Latest Version
On Windows, to upgrade pip first open the windows command prompt and then run the following command to update with the latest available version
# Upgrade to latest available version python -m pip install --upgrade pip
Alternatively, you can also upgrade using.
# Short form python -m pip install -U pip # If you have Python3, you can also use. python3 -m pip install --upgrade pip # If you have Python2, you can also use. python2 -m pip install --upgrade pip
3. Upgrade pip to a Specific Version
Sometimes you may need to downgrade or upgrade pip to a specific ver number, you can achieve this by the below command.
# Upgrade to a specific version python -m pip install pip==18.1
This updates the pip version to 18.1
4. Upgrade pip version on Linux Server
To Upgrade it on a Linux server, you don’t have to use python instead just use pip command either with full or short form
pip install --upgrade pip pip install -U pip
If you have
Python2 installed on your system, running
pip install by default updates pip version on Python2 packages. In order to upgrade pip package on
Python3, use the following.
# If you have Python3, you can also use. pip3 install --upgrade pip # If you have Python2, you can also use. pip2 install --upgrade pip
Sometimes your current user may not have access to run pip commands in that case use
sudo along with the pip command. You may also need a root password in order to run commands with sudo.
sudo -H pip3 install --upgrade pip sudo -H pip2 install --upgrade pip
5. How to Upgrade pip version on Mac OS
Most of all commands explained in the above section with Linux also work for Mac OS. Below is one sample.
# Get current pip version $ pip --version # upgrade pip version $ sudo pip install --upgrade pip
sudo will prompt you to enter your root password.
6. Upgrade pip with Anaconda
In order to update pip version with Anaconda distribution, open the Anaconda command prompt and enter the below command.
# Upgrade using Conda C:\Users\sai>conda update pip
7. Manually Upgrading or Installing pip package
Go to the website https://pypi.python.org/pypi/pip and download the pip binary tar file. You can use
wget command and the URL of the package to download. Below example downloads the pip version 21.2.3
# manually download and upgrade pip version wget https://files.pythonhosted.org/packages/e1/63/7c0e553ae0513ebf1858f08030158ff5998324013e0ba4c2e1c00b85df79/pip-21.2.3.tar.gz tar -xzvf pip-21.2.3.tar.gz cd pip-21.2.3 sudo python3 setup.py install
In this article, you have learned pip command is used to update pip package version as pip is a PyPI package that is similar to other python packages. You also learned the pip commands to use for updates on Linux, Windows & Mac OS.
Happy Learning !!
You May Also Like
- How to upgrade Pandas Version to the new version available?
- How to Get Installed Pandas Version and It’s Dependencies Package Versions?
- How to use Series with Examples.