Install a Specific Version of a Package with PIP

You might have a project which needs a certain specific version of a package, in this post, we're going to highlight how you can install a specific version of a package with pip.

Related: What is pip in Python

What is PIP in Python: The Complete Guide
Ever wondered what pip is and how to use it exactly? Our guide has all the details you will need about pip - python’s package management tool.

Commands for Installing a specific version of a package with pip

To install a specific package version, you can use the pip install command followed by the name and version of the package you want to install.

  • If you want to install the latest version o a package, don't specify a version and use the command pip install <nameofpackage>. Here, you replace the <nameofpackage> with the name of the package you want to install
  • To install the specific version of a package you can use the command pip install nameofpackage==version>. For example, if your package is called qubits and you want to install version 1.0.5 you would use the following command: pip install qubit==1.0.5
  • To specify the minimum version of a package, you can use the command pip install nameofpackage>=version. For example, if you want to install the package qubit with a minimum version of 2.0, your command would be: pip install 'qubit>=2.0.0'.
    Don't forget to wrap the package and version name in single quotes!

Related: How to upgrade pip

How To Upgrade Pip In Windows, MacOS & Linux
A step-by-step guide on how you can update pip on your operating system.

TL;DR

Use the commands below to download the latest, specific, or minimum version of a package with pip.

$ pip install <nameOfPackage> // Install the latest version
$ pip install nameOfPackage==2.0.2 // Install the version requested
$ pip install 'nameOfPackage>=2.0.2 // Specifies the minimum version to be installed
TL; DR - Commands to use

That's all folks!