Skip to content
geeksforgeeks
  • 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
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
How to Install iPython on MacOS?
Next article icon

Install Httpx using Python PIP

Last Updated : 26 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

When working on the internet or building websites, it's important to have good tools to ask for information. HTTPX is one of these tools, and a lot of people like it because it's fast, flexible, and has many features. This article will explain what HTTPX is and show you simple steps to put it on your computer.

What is HTTPX?

HTTPX is a fully featured HTTP client for Python 3, which provides synchronous and asynchronous request handling. It is built on top of the popular httpcore library and designed to be highly performant. HTTPX supports both synchronous and asynchronous programming paradigms, making it suitable for a wide range of applications.

Key features

  • Asynchronous and synchronous support: HTTPX is designed to handle asynchronous requests efficiently using Python's asyncio. However, it also provides a synchronous API for developers who prefer that style of programming.
  • Connection pooling: HTTPX comes with built-in connection pooling for increased performance when making multiple requests to the same server.
  • WebSocket support: In addition to traditional HTTP requests, HTTPX supports WebSocket communication, making it versatile for various real-time applications.

Methods To Install Httpx in Python

Below, are the Methods To Install Httpx in Python.

  • Install HTTPX Using Pip
  • Install HTTPX CLI Using Pip

Install HTTPX Using pip

The most straightforward way to install HTTPX is using the pip package manager. Open your terminal or command prompt and run the following command:

pip install httpx

15

Or, to include the optional HTTP/2 support, use:

pip install httpx[http2]

2

To include the optional brotli decoder support, use:

pip install httpx[brotli]

3

Note: HTTPX requires Python 3.8+

Verify installation after installing httpx using above command.

9

If "import httpx" gets executed successfully in your python environment than it is installed in your system now.

Install HTTPX CLI Using Pip

Another way to install HTTPX is using the CLI pip package manager. Open your terminal or command prompt and run the following command:

pip install httpx[cli]

4

This now allows us to use HTTPX directly from the command line.

10
httpx --help
12
httpx request using CLI

Code Example

Do not name your file as htttpx.py while saving any python file which contains "import httpx" statement because when you try to import httpx, Python first looks in the current directory for a file named httpx.py, and it finds your script instead of the actual httpx library.

Python3
# File is saved as GFG.py  import httpx  async def main():     async with httpx.AsyncClient() as client:         response = await client.get('https://www.shravangoswami.com')         print(response.text)  # Run the async function import asyncio asyncio.run(main()) 

Output:

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shravan Goswami</title>
<meta name="description"
content="Personal website of Shravan Goswami. Stay tuned for updates and connect with me on social media.">
<meta name="keywords"................
.................................................................
..............................................
</a>
<a href="https://www.linkedin.com/in/shravangoswami/" target="_blank">
<i class="fab fa-linkedin" style="color: #00ff00;"></i>
</a>
</div>
</div>
</div>
</body>

Conclusion

HTTPX is a powerful HTTP client for Python, offering a range of features for making HTTP requests efficiently. By following the methods mentioned above, you can easily install HTTPX and begin leveraging its capabilities in your Python projects. Whether you're building web applications, APIs, or conducting network-related tasks, HTTPX provides a reliable and versatile solution for handling HTTP communication in your Python programs.


Next Article
How to Install iPython on MacOS?

S

shravanngoswamii
Improve
Article Tags :
  • Python
  • how-to-install
Practice Tags :
  • python

Similar Reads

  • How To Install PIP Using Ansible ?
    Nowadays the IT culture is evolving with Agile practices and DevOps Culture, on idea of making the business plans, and features quickly to market and making users available. In this software development workflow configuring software and updating the patches to each system manually or through automat
    6 min read
  • How to Install yfinance with Python PIP
    The yfinance API is a powerful tool for accessing financial data from Yahoo Finance. It allows users to download historical market data, retrieve financial information, and perform various financial analyses. This API is widely used in finance, investment, and trading applications for its ease of us
    2 min read
  • How to install PIP in Ubuntu?
    PIP is the most widely used package management system for Python, allowing you to install and manage Python libraries and packages easily. If you're developing in Python on Ubuntu, having PIP installed is essential for downloading and managing the dependencies of your projects. In this guide, we’ll
    3 min read
  • How to Install iPython on Linux?
    Ipython is the famous toolkit that provides the interactive Python shell and also provides the Jupyter Kernel to work with Python code on the Jupyter notebook environment. Jupyter notebook is a web application that is used to create documents that contain executable code, formulas, etc. IPython is a
    2 min read
  • How to Install iPython on MacOS?
    In this article, we will learn how to install iPython in Python on MacOS. IPython is a command shell for interactive computing in multiple programming languages, originally developed for the Python programming language, that offers introspection, rich media, shell syntax, tab completion, and history
    2 min read
  • How to install Python on Windows?
    Python is a high-level programming language that has become increasingly popular due to its simplicity, versatility, and extensive range of applications. The process of How to install Python in Windows, operating system is relatively easy and involves a few uncomplicated steps. This article aims to
    5 min read
  • Find Installed Python Package Version Using Pip
    When working with Python projects, it's important to know which versions of packages are installed in your environment. This helps ensure compatibility, manage dependencies, and troubleshoot issues effectively. Whether you're collaborating on a team, deploying an application, or simply maintaining y
    2 min read
  • How To Install Python Using Ansible Playbook ?
    Automation is now absolutely necessary for the effective management of software deployment and infrastructure in IT landscape. Ansible emerges as a main automation tool, eminent for its effortlessness, simplicity, and flexibility. Software installation, configuration management, and application depl
    7 min read
  • How to Install Pyvista Using Github?
    Pyvista is a powerful and versatile library in Python designed for 3D visualization and analysis of scientific data. It simplifies the process of creating and interacting with 3D plots, making it an excellent tool for researchers, engineers, and data scientists. In this article, we will explore how
    2 min read
  • How to Install Python-USPP on Linux?
    Python-USPP is a multi-platform Python library that allows communication between Python programs and USPP devices. This library is written in Python itself. It supports Windows, Linux, and MacOS. In this article, we will learn how to install this library in the Linux operating system. Python USPP in
    3 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