The Python Requests module is an essential tool for making HTTP requests in Python. It abstracts away much of the complexity of working with URLs, headers, POST data, etc. Installing Requests with Pip helps ensure you have the latest version and makes it easy to add to new Python projects.
Prerequisites
You can check if you have Pip by running:
pip --version
If you don't have Pip, install it first.
Install Requests
Installing Requests is simple with Pip.
Open a command prompt or terminal and enter:
pip install requests
Pip will download the Requests package and dependencies and install them onto your system.
To install a specific version:
pip install requests==2.26.0
To upgrade Requests to the latest version:
pip install --upgrade requests
Check the Installation
To verify Requests installed correctly, open up the Python interpreter and import the module:
>>> import requests
If no errors come up, Requests has installed successfully!
Making Requests
With Requests installed you can start making HTTP requests:
>>> response = requests.get('https://api.example.com')
See the Requests documentation for more details on usage.
Installing modules with Pip helps manage dependencies and keep your projects up to date. Requests is one of the most useful Python modules for working with HTTP APIs and websites.