English 中文(简体)
Requests - Environment Setup
  • 时间:2024-12-22

Requests - Environment Setup


Previous Page Next Page  

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

Instalpng Python

Go to the Python official site: https://www.python.org/downloads/ as shown below and cpck 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.

Python Download

Once you have downloaded, cpck on the .exe file and follow the steps to install python on your system.

Python For Windows

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-cpck on your Computer icon and cpck on properties > Advanced System Settings.

It will display the screen as shown below −

System properties

Cpck on Environment Variables as shown above. It will display the screen as shown below −

Environment Variables

Select Path and cpck 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:usersxxxxxappdatalocalprogramspythonpython37pbsite-
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
pythonpython37pbsite-packages (2.22.0)
Requirement already satisfied: certifi>=2017.4.17 in c:userskamatappdatalocal
programspythonpython37pbsite-packages (from requests) (2019.3.9)
Requirement already satisfied: urlpb3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:use
rsxxxxxappdatalocalprogramspythonpython37pbsite-packages (from requests
) (1.25.3)
Requirement already satisfied: idna<2.9,>=2.5 in c:usersxxxxxxxappdatalocal
programspythonpython37pbsite-packages (from requests) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:usersxxxxxappdata
localprogramspythonpython37pbsite-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: me@kennethreitz.org
License: Apache 2.0
Location: c:usersxxxxxappdatalocalprogramspythonpython37pbsite-package
S
Requires: certifi, idna, urlpb3, chardet
Required-by:

The version of Requests module is 2.22.0.

Advertisements