How to Install Python Requests Module in Linux
If you are a developer using Python for web development or data analysis, you will likely need to use the Python Requests module to make HTTP requests. Here is how you can install the module in Linux:
Method 1: Using pip (Preferred Method)
The easiest and most common way to install Python Requests module is by using pip. If you don't have pip installed, first install it using the following command:
$ sudo apt-get install python-pip
Once pip is installed, you can install the requests module by running the following command:
$ sudo pip install requests
This command will download the latest version of requests module from PyPI (Python Package Index) and install it on your system.
Method 2: Using apt-get
If you prefer to install packages via apt-get, you can use the following command:
$ sudo apt-get install python-requests
This command will install the requests module from the official Ubuntu repositories.
Method 3: Manual installation
If you want to install the module manually, you can download the source code from the official website and install it using the following commands:
$ wget https://github.com/psf/requests/archive/refs/tags/v2.26.0.tar.gz
$ tar -xvf v2.26.0.tar.gz
$ cd requests-2.26.0/
$ sudo python setup.py install
This method is not recommended as it requires more effort and may cause compatibility issues.
Conclusion
There are multiple ways to install the Python Requests module in Linux. The easiest and most recommended method is using pip. If you prefer to use apt-get, you can install it from the official repositories. Manual installation is also an option, but is not recommended.