Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correct ModuleNotFoundError for http.client

I am trying to use the urllib library as part of a python program for web scraping. It contains the module request.py which has to import http.client. However I keep on getting this message:

ModuleNotFoundError: No module named 'http.client'; 'http' is not a package.

However, my Python libraries folder "Lib" contains both http folder and urllib folder. The http folder also contains client.py file. What could possibly be wrong? Please help I'm a beginner.

like image 469
Paulina Mensah Avatar asked Feb 01 '26 10:02

Paulina Mensah


1 Answers

In python you cannot override your packages. You maybe have another module in your code called "http". Just change it to "web" or any name you like and it should work.

This was an issue I had in my project.

like image 127
juliancamilo alvarez Avatar answered Feb 03 '26 23:02

juliancamilo alvarez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!