A Detailed Guide About Installing Specific Package Versions with Pip and Python? 

Installing Specific Package Versions with Pip and Python
InfinitySoftHint Updated Logo

Empower Your Knowledge

We recommend that you study InfinitySoftHint’s helpful and informative blogs so you can enhance your knowledge, stay up to date on the latest technology, read about new, upcoming problems and their solutions, and learn marketing and lead generation tips and ideas.

Table of Content

Python is the most in-demand and widely used programming language due to its vast ecosystem of libraries, readability, and simplicity. You can run programs consistently using their latest version of packages, which is responsible for expanding Python’s capability to build and develop data scientist pipelines to web applications with remarkable efficiency. Package version control reduces the risk of incompatibility and bugs and allows developers to install the latest version of libraries.

When developers install the latest Python packages to maintain the capability with their code base across different environments, it easily runs, and they test and deploy. Old versions of Python create unexpected bugs, or old code bases with new libraries are no longer supported, creating bugs that affect workflow. In this scenario, controlling package versions is the best way to solve this problem. Tasks like installing specific versions or downgrading packages are among the simple Python tasks that can help resolve bugs and streamline development efforts.

Two tools facilitate the installation of the latest Python packages. One is pip, which supports installing Python packages on Windows. This is the Python-specific package that fetches the packages from the Python Package Index, which provides a virtual environment for programming. The second one is apt, which is used in Linux systems; it has fewer Python-specific needs. It is good for system-wide installation. Understanding how to use them saves a lot of time for developers to make them work efficiently.

In this guide, I’ll explain how to use pip to install a specific version, downgrade packages, apt install a specific version, and downgrade pip itself step-by-step for beginners so they can easily install Python packages.

Understanding ‘pip install’ for Installing Specific Package Versions

The standard package installation tool on Python Package Index (PyPI) is In 2025, version 25.0.1 of pip functions as the standard package installation tool on Python Package Index (PyPI). Through simple commands, pip enables developers to effectively manage their development environment through seamless installations and upgrades, or uninstalls of libraries. By default, pip installs the latest available version of a package. However, this may not always be ideal for certain programming needs.

Developers often need to install specific package versions to ensure compatibility with existing systems while developing software. When a new package is launched, it makes changes or function removals, and dependency conflicts can appear across your project. Code reproducibility requires consistent package versions, which help with debugging legacy codebases, especially when multiple development teams are involved.

The == syntax in pip enables users to install specific packages. Best practice standards in virtual environments combine with continuous integration pipelines to support this syntax and all applications that reach the production phase.

Syntax for Installing a Specific Version Using pip

To install an exact version of a package, use

pip install requests==2.28.1

Pip understands the == operator to retrieve version 2.28.1 exclusively for the requests library installation. The dependency resolution of Pip 25.0.1 performs clean resolution while notifying you about version conflicts.

Installing a Range of Versions

Sometimes you need flexibility, so you can specify a version range like this:

pip install "requests>=2.20,<2.30" Pip will install any requested version between 2.20 and 2.30, without including 2.30.

You can also use the compatible release operator (~=), which ensures compatibility with minor updates:

pip install "requests~=2.28.0"

The command will download the most recent version, 2.28, while avoiding any versions higher than 2.28.1 or 2.28.2.

How to downgrade a package with pip?

Package downgrading in Python development involves installing an older library version for a dependent program. Most developers apply this step because the current package version contains bugs, causing compatibility issues or removing essential attributes necessary for code execution. Library updates may have introduced breaking changes that cause your application to crash, while a dependency might work with only older versions.

Thankfully, with pip (v25.0. In 2025 (pip version 25.0.1), you can perform a package downgrade operation by running the same installation command. You simply use the same pip install command with the target version number:

pip install <package-name>==<older-version>

<package-name> : it is the name of the package you want to downgrade (e.g requests)

<older-version> : it is the version you want to install

Fast upgrades become feasible using this method, although it proves insufficient for complex dependency troubleshooting situations.

Step-by-Step: pip Downgrade Package Example

1. Check the current version:

pip show requests

2. Downgrade the package:

pip install requests==2.25.1

3. Confirm the change:

pip show requests

Tip: To see all available versions of a package, use

pip install requests==

A list of available versions for manual selection will be returned to your terminal.

Uninstalling First vs. Direct Downgrade

You can downgrade in two main ways:

Option 1: Uninstall, then reinstall:

Uninstall Package:

pip uninstall requests

Running this command makes sure every old version is properly removed before installing an earlier version.

Reinstall Package:

pip install requests==2.25.1

This command will re-install requests with the specified version

Option 2: Direct downgrade with force:

pip install requests==2.25.1 --force-reinstall

A quick package downgrade generally works well, yet you might need supplementary steps to identify all dependencies.

You can use either method to downgrade to pip 25.0.1; however, forced re-installation via --force-reinstall remains the better choice for rapid version replacements.

Pip Vs apt Package in Python

How to Install a System-Wide Specific Version of a Python Package using APT?

Linux systems that use Ubuntu or Debian operate with the apt package manager to install system-level packages such as Python and pip, yet developers choose pip for Python package management within their development environment. APT functions solely as a system-level package manager that ignores virtual environment package management.

Through apt, you can add Python interpreters and system utilities, and python3-pip, but it cannot automatically install requests alongside python3-pip or pandas or numpy into your Python environment.

Python version installation through apt operates based on your operating system’s package repositories, yet this command enables the setup of server-wide pip installations.

apt Command Syntax and Examples

1. To install a specific version of python3-pip:

sudo apt install python3-pip=20.0.2-5ubuntu1

2. To list all available versions:

apt list -a python3-pip

From this interface, you can access all officially supported versions released by your distribution.

Why Apt May Not Be Ideal for Python Package Management

Using apt for Python packages has several limitations:

  1. Fewer versions available than what’s on PyPI
  2. Slower updates, depending on your distro’s release cycle
  3. Dependency issues that may affect other system packages

Through virtualenv and venv, Python offers better package separation that enhances pip functionality. Using this way, teams can effectively handle dependencies that support single projects and maintain distinct configuration systems.

How to downgrade pip for itself?

Even though pip continues to advance ( at version 25.0.1 in 2025), you may need to install previous versions occasionally. Developers frequently require pip downgrades while working with old projects and infrastructure components and packages that cannot use modern pip capabilities.

You can easily perform pip downgrades through the pip utility itself. You can set a specific version to install the command to specify which pip version you need to install.

Confirming Your pip Version

  • Before downgrading, check your current pip version:
pip --version

You’ll see something like

pip 25.0.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)

  • Downgrade Syntax

To downgrade pip to a specific version (e.g., 20.2.4):

python -m pip install pip==20.2.4

The specified version of pip will become the active version after this command executes.

Use python3 it if python it causes an issue.

Tips for Downgrading Safely

  1. Always use a virtual environment (venv or virtualenv) to avoid system-wide changes:
python -m venv env

To activate the environment in Linux use:

source env/bin/activate

To activate the environment in Windows use:

env\bin\activate
  1. Check pip functionality following the downgrade to verify system compatibility.
  2. Use pipx if you want to isolate pip versions without affecting your core environment:
pipx install pip==20.2.4

Stability and reproducibility of operations during pip downgrades depend on following security best practices.

Conclusion

In this article, I explained how a beginner installs pip packages in Python. Many developers face issues when new packages are launched and their code base does not recognize them. In this case, downgrading the package with pip can help. Linux users rely on apt, which supports Python packages, but it lacks flexibility

Recent Blogs