• Post author:
  • Post category:Python
  • Post last modified:September 25, 2024
  • Reading time:14 mins read
You are currently viewing Different Ways to Upgrade PIP Latest or Specific Version

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.

Advertisements

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 pip --version


(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
python pip upgrade latest version

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

Frequently Asked Questions On Pip Version Upgrade

Why should I upgrade pip?

Upgrading pip is important for several reasons, including bug fixes, security updates, and access to new features. It ensures that you have the latest and most stable version of the package manager, which is crucial for managing Python packages effectively.

How can I check the current version of pip installed?

You can check the installed version of pip by running the following command in your terminal or command prompt.

What is the difference between upgrading pip using pip install –upgrade pip and python -m pip install –upgrade pip?

Both commands achieve the same result—upgrading pip to the latest version. The difference lies in how the commands are executed. The python -m pip syntax is a way to run the pip module as a script using the python interpreter, while pip install is a more direct command.

Can I specify a particular version of pip to install or upgrade to?

You can specify a particular version of pip when installing or upgrading. For example, to upgrade to version 21.3.1, use

Is there a recommended frequency for upgrading pip?

It’s good practice to check for pip updates regularly and upgrade when necessary. Checking for updates and upgrading every few weeks or before starting a new project is a reasonable frequency to ensure you have the latest features and security patches.

Are there system-specific commands to upgrade pip?

On systems with package managers, you can use system-specific commands. For example, on Linux with apt, you can run

Conclusion

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 !!

References

This Post Has One Comment

  1. Ngomba Jonathan

    Thank you for this helpfull and shortest way to Upgrade, up… Python PIP!

Comments are closed.