# Pip Install Specific Version of a Python Package

> Use pip install package==version to install a specific release, with pip automatically replacing any existing version, and lock versions in requirements.txt

**URL:** https://sentry.io/answers/install-a-specific-version-of-a-python-package-using-pip/

---

## The Problem

How do I install a specific, older version of a Python package using PIP? Will it matter if I have another version already installed?

## The Solution

We can install an older version of a specific package by using the following syntax in our PIP command:

```bash
pip install requests==2.30.0
```

The `==` syntax allows us to specify a version number. We can see which version numbers are available by looking at the [release history](https://pypi.org/project/requests/#history) on the package's page on [PyPI.org](https://pypi.org/project/requests/#history).

Note that, on Windows, the package name and version should be surrounded by quotation marks:

```batch
pip install "requests==2.30.0"
```

If a different version of the package is already installed, pip will automatically replace it with the specified version. The [`--force-reinstall`](https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-force-reinstall) flag is only needed when the requested version is the same as what is already installed, since pip would otherwise consider the requirement already satisfied.

To ensure that future users of our project install the correct package versions when setting it up, we should create a requirements file. This is a file in our project's root directory named `requirements.txt`, which contains a list of [requirement specifiers](https://pip.pypa.io/en/stable/reference/requirement-specifiers/) (i.e. package names and versions) on which our project depends. For this example, our requirements file would have one line:

```
requests==2.30.0
```

We would then be able to install the correct version of this and any other packages added by running the following PIP command:

```bash
pip install -r requirements.txt
```

To avoid changing the packages on our entire system for individual Python projects, we can use a [virtual environment](https://docs.python.org/3/library/venv.html). This is the recommended way to deal with Python dependencies in most circumstances.

---

*Source: [sentry.io/answers/install-a-specific-version-of-a-python-package-using-pip/](https://sentry.io/answers/install-a-specific-version-of-a-python-package-using-pip/)*
