Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • webscraping
  • Beautiful Soup
  • Selenium
  • Scrapy
  • urllib
  • open cv
  • Data analysis
  • Machine learning
  • NLP
  • Deep learning
  • Data Science
  • Interview question
  • ML math
  • ML Projects
  • ML interview
  • DL interview
Open In App
Next Article:
GET method - Python requests
Next article icon

How to Install Requests in Python - For Windows, Linux, Mac

Last Updated : 09 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Requests is an elegant and simple HTTP library for Python, built for human beings. One of the most famous libraries for Python is used by developers all over the world. This article revolves around how one can install the requests library of Python in Windows/ Linux/ macOS using pip.

Table of Content

  • Install Requests Module in Python in Window
  • Install Requests Module in Python in Linux
  • Install Requests Module in Python in MacOS
  • Alternative Methods
  • Troubleshooting Tips
  • Install Requests Module in Python - FAQs

Install Requests Module in Python in Window

For installing requests in Windows, you need to Install Python (preferably the latest version) first, follow these simple steps to Install Python on Windows:

Steps to Install Python 3 on Windows

  1. Download the Installer:
    • Visit the official Python website: python.org.
    • Go to the Downloads section and click on “Download Python 3.x.x” (the latest version).
  2. Run the Installer:
    • Locate the downloaded installer file (python-3.x.x.exe) and run it.
  3. Select Installation Options:
    • Check the box that says “Add Python to PATH” at the bottom of the installer window.
    • Choose “Install Now” for a standard installation or “Customize Installation” to choose specific features and installation location.
  4. Customize Installation (Optional):
    • If you chose “Customize Installation,” select optional features like pip, tcl/tk, and documentation.
    • Choose the installation location or accept the default.
  5. Complete the Installation:
    • The installer will copy the necessary files and set up Python on your system.
    • Once the installation is complete, you can close the installer.

Note: You may also refer to this article to get the in-depth details - How to download and install Python Latest Version on Windows

Now open the command prompt from Windows and run the following command:

python -m pip install requests

Booom..!! Done Now this is how you can install Requests Module using pip.

Install Requests Module in Python in Linux

For installing requests in Linux, you need to Install Python (preferably the latest version) first, follow these simple steps to Install Python on Linux:

Steps to Install Python 3 on Linux

Note: If you want to check if Python is already installed in your system then you may run this command in terminal: python --version (This will display the current running version of Python in your Linux)

  1. Download the Installer:
    • Visit the official Python website: python.org.
    • Go to the Downloads section and click on “Download Python 3.x.x” (the latest version).
  2. Run the Installer:
    • Locate the downloaded installer file or use Linux distribution's package manager.
  3. Install Python:
    • Run the following command to install Python: sudo apt python3
  4. Verify Python Installation:
    • Once the installation is complete, verify it by running this command: python3 --version

Note: Alternatively, you may visit this article to read on Installation Guide:

How to download and install Python Latest Version on Linux

To install pip in linux: How to install PIP in Linux?

Install Requests Module in Python in MacOS

For installing requests in MacOS, you need to Install Python (preferably the latest version) first, follow these simple steps to Install Python on macos:

  1. Download the Installer:
    • Visit the official Python website: python.org.
    • Open the downloaded .pkg file (e.g., python-3.x.x-macosx.pkg).
  2. Run the Installer:
    • Locate the downloaded installer file and follow the on-screen instructions.
  3. Verify Python Installation:
    • Once the installation is complete, verify it by running this command: python3 --version

Note: Alternatively, you may visit this article to read on Installation Guide:

Install Python Latest Version on MacOS

To install pip macOS. Run the following command

sudo easy_install pip sudo pip install --upgrade pip 

Now to install requests,

pip install requests

Alternative Methods

The last method for installation of requests on any operating system is to grab the base files and install requests manually and Requests is actively developed on GitHub, where the code is always available. For code -

You can either clone the public repository:

git clone git://github.com/psf/requests.git

Or, download the tarball:

curl -OL https://github.com/psf/requests/tarball/master # optionally, zipball is also available (for Windows users).

Once you have a copy of the source, you can embed it in your own Python package, or install it into your site-packages easily:

cd requests pip install .

Troubleshooting Tips

While installing Requests, you might encounter some issues. Here are a few troubleshooting tips for different operating systems:

  1. pip not recognized (Windows or macOS):
    • If you get an error like "pip: command not found" or "pip is not recognized", make sure Python and pip are added to your PATH environment variable.
  2. Permission Issues (Linux/macOS):
    • If you get a Permission Denied error, try running the installation with sudo (Linux/macOS):
      sudo pip3 install requests
  3. Outdated pip Version:
    • If you're getting errors about an outdated version of pip, upgrade pip using:
      pip install --upgrade pip
  4. Version Conflicts (Multiple Python Versions):
    • If you have multiple versions of Python, make sure you're using the correct version of pip (e.g., pip3 for Python 3).

Conclusion

Installing the Requests library in Python is straightforward on Windows, Linux, and macOS. If you're looking to manage HTTP requests or interact with APIs, the Requests library is an essential tool for your Python projects.

By following the steps outlined in this guide, you can easily set up Requests on any major operating system. Make sure you’re using the latest versions of Python and pip to ensure compatibility with the latest updates to Requests.


Next Article
GET method - Python requests

N

NaveenArora
Improve
Article Tags :
  • Python
  • How To
  • Installation Guide
  • Python-requests
  • how-to-install
Practice Tags :
  • python

Similar Reads

    Python Requests
    Python Requests Library is a simple and powerful tool to send HTTP requests and interact with web resources. It allows you to easily send GET, POST, PUT, DELETE, PATCH, HEAD requests to web servers, handle responses, and work with REST APIs and web scraping tasks.Features of Python Requests LibraryS
    5 min read

    Getting Started with python-requests

    What is Web Scraping and How to Use It?
    Suppose you want some information from a website. Let’s say a paragraph on Donald Trump! What do you do? Well, you can copy and paste the information from Wikipedia into your file. But what if you want to get large amounts of information from a website as quickly as possible? Such as large amounts o
    7 min read
    How to Install Requests in Python - For Windows, Linux, Mac
    Requests is an elegant and simple HTTP library for Python, built for human beings. One of the most famous libraries for Python is used by developers all over the world. This article revolves around how one can install the requests library of Python in Windows/ Linux/ macOS using pip.Table of Content
    7 min read

    HTTP Request Methods

    GET method - Python requests
    Requests library is one of the important aspects of Python for making HTTP requests to a specified URL. This article revolves around how one can make GET request to a specified URL using requests.GET() method. Before checking out GET method, let's figure out what a GET request is - GET Http Method T
    2 min read
    POST method - Python requests
    Requests library is one of the important aspects of Python for making HTTP requests to a specified URL. This article revolves around how one can make POST request to a specified URL using requests.post() method. Before checking out the POST method, let's figure out what a POST request is -   POST Ht
    2 min read
    PUT method - Python requests
    The requests library is a powerful and user-friendly tool in Python for making HTTP requests. The PUT method is one of the key HTTP request methods used to update or create a resource at a specific URI.Working of HTTP PUT Method If the resource exists at the given URI, it is updated with the new dat
    2 min read
    DELETE method- Python requests
    Requests library is one of the important aspects of Python for making HTTP requests to a specified URL. This article revolves around how one can make DELETE request to a specified URL using requests.delete() method. Before checking out the DELETE method, let's figure out what a Http DELETE request i
    2 min read
    HEAD method - Python requests
    Requests library is one of the important aspects of Python for making HTTP requests to a specified URL. This article revolves around how one can make HEAD request to a specified URL using requests.head() method. Before checking out the HEAD method, let's figure out what a Http HEAD request is - HEAD
    2 min read
    PATCH method - Python requests
    Requests library is one of the important aspects of Python for making HTTP requests to a specified URL. This article revolves around how one can make PATCH request to a specified URL using requests.patch() method. Before checking out the PATCH method, let's figure out what a Http PATCH request is -
    3 min read

    Response Methods

    response.headers - Python requests
    The response.headers object in Python's requests library functions as a special dictionary that contains extra information provided by the server when we make an HTTP request. It stores metadata like content type, server details and other headers, such as cookies or authorization tokens. The keys in
    3 min read
    response.encoding - Python requests
    Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves
    2 min read
    response.elapsed - Python requests
    Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves
    2 min read
    response.close() - Python requests
    Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves
    2 min read
    response.content - Python requests
    When you make an HTTP request in Python using the requests library, it returns a response object. One of the most important attributes of this object is response.content, which gives you the raw response body in bytes. This is especially useful when dealing with binary data like images, PDFs, audio
    1 min read
    response.cookies - Python requests
    Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves
    2 min read
    response.history - Python requests
    Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves
    2 min read
    response.is_permanent_redirect - Python requests
    Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves
    2 min read
    response.is_redirect - Python requests
    Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves
    2 min read
    response.iter_content() - Python requests
    response.iter_content() iterates over the response.content. Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain fe
    2 min read
    response.json() - Python requests
    Python requests are generally used to fetch the content from a particular resource URL. Whenever we make a request to a specified URL through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves
    3 min read
    response.url - Python requests
    response.url returns the URL of the response. It will show the main url which has returned the content, after all redirections, if done. Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a
    2 min read
    response.text - Python requests
    In Python’s requests library, the response.text attribute allows developers to access the content of the response returned by an HTTP request. This content is always returned as a Unicode string, making it easy to read and manipulate. Whether the response body contains HTML, JSON, XML, or plain text
    3 min read
    response.status_code - Python requests
    response.status_code returns a number that indicates the status (200 is OK, 404 is Not Found). Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object
    2 min read
    response.request - Python requests
    response.request returns the request object that requested this response. Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to acc
    2 min read
    response.reason - Python requests
    response.reason returns a text corresponding to the status code. for example, OK for 200, Not Found for 404. Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this r
    2 min read
    response.raise_for_status() - Python requests
    We are given a scenario where we use the Python requests library to make HTTP calls, and we want to check if any error occurred during the request. This can be done using the raise_for_status() method on the response object. For example, if we request a page that doesn't exist, this method will rais
    3 min read
    response.ok - Python requests
    response.ok returns True if status_code is less than 400, otherwise False. Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to ac
    2 min read
    response.links - Python requests
    response.links returns the header links. To know more about Http Headers, visit - Http Headers. Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response objec
    2 min read
    Convert JSON data Into a Custom Python Object
    Let us see how to convert JSON data into a custom object in Python. Converting JSON data into a custom python object is also known as decoding or deserializing JSON data. To decode JSON data we can make use of the json.loads(), json.load() method and the object_hook parameter. The object_hook parame
    2 min read
    Authentication using Python requests
    Authentication refers to giving a user permissions to access a particular resource. Since, everyone can't be allowed to access data from every URL, one would require authentication primarily. To achieve this authentication, typically one provides authentication data through Authorization header or a
    2 min read
    SSL Certificate Verification - Python requests
    Requests verifies SSL certificates for HTTPS requests, just like a web browser. SSL Certificates are small data files that digitally bind a cryptographic key to an organization's details. Often, a website with a SSL certificate is termed as secure website. By default, SSL verification is enabled, an
    2 min read
    Exception Handling Of Python Requests Module
    Python's requests module is a simple way to make HTTP requests. In this article, we’ll use the GET method to fetch data from a server and handle errors using try and except. This will help us understand how to manage situations where the request fails or returns an error."url: Returns the URL of the
    3 min read
    Memory Leak in Python requests
    When a programmer forgets to clear a memory allocated in heap memory, the memory leak occurs. It's a type of resource leak or wastage. When there is a memory leak in the application, the memory of the machine gets filled and slows down the performance of the machine. This is a serious issue while bu
    5 min read

    Projects

    How to get the Daily News using Python
    In this article, we are going to see how to get daily news using Python. Here we will use Beautiful Soup and the request module to scrape the data. Modules neededbs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not come built-in with Python. T
    3 min read
    How to Build Web scraping bot in Python
    In this article, we are going to see how to build a web scraping bot in Python. Web Scraping is a process of extracting data from websites. A Bot is a piece of code that will automate our task. Therefore, A web scraping bot is a program that will automatically scrape a website for data, based on our
    8 min read
    Send SMS with REST Using Python
    In this article, we are going to see how we can send SMS with REST using Python. The requests library can be used to make REST requests using Python to send SMS.  Approach:You need to first create a REST API KEY for sending SMS using Python Script. We have used Fast2SMS for creating API KEY.You can
    2 min read
    How to check horoscope using Python ?
    In this article, we are going to see how to get a horoscope a day before, on that day as well as the day after using Beautifulsoup. Module needed:bs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not come built-in with Python. To install this t
    4 min read
    Web Scraping - Amazon Customer Reviews
    In this article, we are going to see how we can scrape the amazon customer review using Beautiful Soup in Python. Module neededbs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not come built-in with Python. To install this type the below comma
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences