Installing a Specific Version of the Requests Library in Python

Feb 1, 2024 ยท 1 min read

The Python Requests library is extremely popular for making HTTP requests in Python. By default when you pip install requests it will install the latest version. However, sometimes you may need to install a specific older version for compatibility reasons. Here are a few methods to install an older Requests version.

Using pip and Version Specifiers

The easiest way is to use pip and pass a version specifier to install an older version:

pip install requests==2.22.0

This will install Requests 2.22.0 specifically.

You can also use other specifiers like >= and <=:

pip install 'requests>=2.20.0,<2.23'

This will install the latest 2.22.x version but not any newer 2.23+ releases.

Installing from a requirements.txt File

Another good practice is to have a requirements.txt file that pins all your dependencies to specific versions.

For example your file would contain:


Then you can run:

pip install -r requirements.txt

This ensures you always get the exact pinned versions in your file.

Creating a Virtual Environment

It's also good practice to install packages within a virtual environment instead of globally. This keeps different project's dependencies isolated.

You can create one and install an older Requests version in it:

python -m venv myenv
source myenv/bin/activate
pip install requests==2.20.0

Now Requests 2.20.0 will be installed local to that environment only.


I hope these tips help you install an older version of Requests! The key is using pip version specifiers, requirements.txt files, and virtual environments to manage versions.

Browse by language:

The easiest way to do Web Scraping

Get HTML from any page with a simple API call. We handle proxy rotation, browser identities, automatic retries, CAPTCHAs, JavaScript rendering, etc automatically for you

Try ProxiesAPI for free

curl ""

<!doctype html>
    <title>Example Domain</title>
    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />


Don't leave just yet!

Enter your email below to claim your free API key: