ModuleNotFoundError: No module named 'requests_html'
Fixes the plain missing-module error for requests-html. Use when `from requests_html import HTMLSession` fails with ModuleNotFoundError naming requests_html. Not for the parse/lxml import breakages inside the package.
requests-html is not installed where your script runs. The PyPI name is requests-html (with a dash) but the import is requests_html (with an underscore). Run python -m pip install requests-html and the import works.
The error
ModuleNotFoundError: No module named 'requests_html'Fix it
- Install requests-html
python -m pip install requests-htmlExpected: Successfully installed requests-html-... plus its dependencies.
- Confirm
python -c "from requests_html import HTMLSession; print('ok')"Expected: prints ok.
When this applies
- any
from requests_html import ...fails namingrequests_html - a fresh env following a tutorial
When it does NOT apply
cannot import name 'search' from 'parse'means requests-html IS installed but its dependency broke- the lxmlhtmlclean ImportError is the lxml 5.2 split
Compatibility
requests-html 0.10.x. Note the project is unmaintained since 2021, so expect dependency friction on modern Python (the parse and lxml skills in this set cover the two big ones).
Why it happens
The distribution name uses a dash (requests-html) while the import uses an underscore (requests_html). People who guess the pip name from the import name (pip install requests_html) get nothing, and people who skip the install get this ModuleNotFoundError.
Edge cases
pip install requests_html(underscore) fails outright on PyPI. The dash form is the only one that exists.- Because the project is unmaintained, a fresh install on Python 3.12+ may immediately hit the
parseorlxml_html_cleanerrors. Those have their own fixes.