1

I'm making a python program to test a web-server I am making. I use httpx and wanted to use http2 as well, to be able to send http version 2 requests. The only way I find to install it is pip install httpx[http2], but pip is not working on WSL (error: externally-managed-environment). I got around this with https by doing python3-pip install httpx but python3-pip install httpx[http2] does not seem to work or any other variants I have tried.

To clarify both my web server and python program is running in WSL.

The error that made me look into http2 was:

Error: Using http2=True, but the 'h2' package is not installed. Make sure to install httpx using `pip install httpx[http2]`.

asked Apr 21, 2025 at 13:49
1
  • python3-pip or pip both run the risk of installing for a different environment than you're actually using. python -m pip by contrast always runs pip for the same environment that provides your python. Commented Apr 21, 2025 at 14:49

1 Answer 1

1

httpx[http2] just adds the h2 package try adding it manually by :

python3 -m pip install --user httpx h2

and i recommend to use virtual environment as it avoids any system level limitations:

python3 -m venv venv
source venv/bin/activate
pip install httpx[http2]

it should work now

answered Apr 21, 2025 at 13:57
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.