”;
In this chapter, we will work on the installation of Requests. To start working with the Requests module, we need to install Python first. So we are going to work on following −
- Install Python
- Install Requests
Installing Python
Go to the Python official site: https://www.python.org/downloads/ as shown below and click on the latest version available for Windows, Linux/Unix, and Mac OS. Download Python as per your 64 or 32 bit OS available with you.
Once you have downloaded, click on the .exe file and follow the steps to install python on your system.
The python package manager, i.e., pip will also get installed by default with the above installation. To make it work globally on your system, directly add the location of python to the PATH variable. The same is shown at the start of the installation to remember to check the checkbox which says ADD to PATH. In case you forget to check it, please follow the below-given steps to add to PATH.
To add to PATH follow the steps −
Right-click on your Computer icon and click on properties > Advanced System Settings.
It will display the screen as shown below −
Click on Environment Variables as shown above. It will display the screen as shown below −
Select Path and click on Edit button, add the location path of your python at the end. Now, let us check the python version.
Checking the python version
E:prequests>python --version Python 3.7.3
Install Requests
Now that we have python installed, we are going to install Requests.
Once python is installed, python package manager i.e. pip will also get installed. Following is the command to check pip version.
E:prequests>pip --version pip 19.1.1 from c:usersxxxxxappdatalocalprogramspythonpython37libsite- packagespip (python 3.7)
We have pip installed and the version is 19.1.1. Now, will use pip to install Requests module.
The command is given below −
pip install requests
E:prequests>pip install requests Requirement already satisfied: requests in c:usersxxxxappdatalocalprograms pythonpython37libsite-packages (2.22.0) Requirement already satisfied: certifi>=2017.4.17 in c:userskamatappdatalocal programspythonpython37libsite-packages (from requests) (2019.3.9) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:use rsxxxxxappdatalocalprogramspythonpython37libsite-packages (from requests ) (1.25.3) Requirement already satisfied: idna<2.9,>=2.5 in c:usersxxxxxxxappdatalocal programspythonpython37libsite-packages (from requests) (2.8) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:usersxxxxxappdata localprogramspythonpython37libsite-packages (from requests) (3.0.4)
We already have the module installed, so in the command prompt it says Requirement already satisfied; if not installed it would have downloaded the required packages for installation.
To check the details of the requests module installed, you can use the following command −
pip show requests E:prequests>pip show requests Name: requests Version: 2.22.0 Summary: Python HTTP for Humans. Home-page: http://python-requests.org Author: Kenneth Reitz Author-email: [email protected] License: Apache 2.0 Location: c:usersxxxxxappdatalocalprogramspythonpython37libsite-package S Requires: certifi, idna, urllib3, chardet Required-by:
The version of Requests module is 2.22.0.
”;