How To Update/Upgrade A Python Package with Pip? – POFTUT

How To Update/Upgrade A Python Package with Pip?

Pip is a popular command used to manage Python packages.  Pip command is also used for updating/upgrading already installed Python packages.

List Installed Packages

Before updating or upgrading an installed Python package we will list already installed packages. We will use the list command which will display the complete name and the version of the installed packages.

List Installed Packages

List Installed Packages

Check If A Python Package Is Installed

In the previous example, we have just listed all installed packages and versions. We can also check if a specific python package is already installed. We will also use grep command by providing the name of the package we want to check.

Check If A Python Package Is Installed

Check If A Python Package Is Installed

List Outdated Python Packages

Pip command also provides --outdated options with the list command which will list outdated and already installed python packages.

List Outdated Python Packages

List Outdated Python Packages

Upgrade/Update Python Package To The Latest Version

We will use the install command with the --upgrade option and also provide the package name. In this example, we will update/upgrade the package named Django to the latest version. We will also provide the --user option. Alternatively to the --upgrade we can use -U which is the short form.

LEARN MORE  How To Install Pip On MacOS?

Upgrade/Update Python Package To The Latest Version

Upgrade/Update Python Package To The Latest Version

From the screenshot, we see that first the Django version 2.0 is found. Django version 2.0 is uninstalled and then Django version 2.2.5 is installed which will complete the upgrade/update of the Django.

Upgrade/Update Python Package To The Specific Version

In the previous example, we have updated the Django python package to the latest version. We can also update/upgrade a python package into a specific version which is not latest. In this example, we will upgrade/update a specific version which is not latest with the equal signs. We will not use the --upgrade option but specify the upgraded version.

Upgrade/Update Python Package To The Specific Version

Upgrade/Update Python Package To The Specific Version

We can see that the currently installed version is Django 2.0 but we will upgrade it into version 2.2 .

Downgrade Python Package To The Specific Version

We can also downgrade the installed package into a specific version. We will specify the Python package name with the version we want to downgrade by using equation signs like below. In this example, we will downgrade the Django package to version 2.0 .

LEARN MORE  How To Install Pip on Windows?

Downgrade Python Package To The Specific Version

Downgrade Python Package To The Specific Version

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)