ImportError: cannot import name 'search' from 'parse'
Fixes requests-html breaking against parse 1.20+, which removed the `search` function it imports. Use when `from requests_html import HTMLSession` raises ImportError naming `search` from `parse`. Not for missing requests_html itself.
requests-html does from parse import search at load, and parse 1.20 removed that function. Pin parse back with python -m pip install 'parse==1.19.1' and the import works. This is a dependency-version problem, not a broken requests-html install, so reinstalling requests-html alone changes nothing.
The error
ImportError: cannot import name 'search' from 'parse'Fix it
- Pin parse to the last working release
python -m pip install 'parse==1.19.1'Expected: pip installs parse 1.19.1.
- Confirm the import
python -c "from requests_html import HTMLSession; print('ok')"Expected: prints ok.
- Keep the pin
Add parse==1.19.1 next to requests-html in your requirements so a fresh install does not pull parse 1.20+ again. Expected: reproducible installs stay working.
When this applies
- the ImportError names
searchfromparsewhen importing requests_html - it broke after a
pip install -Upulled parse 1.20+ - the traceback points at requests_html's own import lines, not your code
When it does NOT apply
No module named 'requests_html'is the missing installNo module named 'parse'means parse is absent entirely (install any parse)
Compatibility
requests-html 0.10.0 with parse >= 1.20. parse 1.19.1 is the last version shipping search. requests-html is unmaintained, so no upstream fix is coming.
Why it happens
requests-html imports the search helper from the parse library at module load time. parse 1.20 refactored its API and dropped search. Because requests-html declares no upper bound on parse, any fresh resolver picks the newest parse and the import dies. The project has had no release since 2021, so the ecosystem fix is the pin, not an upgrade.
Edge cases
- If another package needs parse>=1.20, you have a genuine conflict. Isolate requests-html in its own venv; there is no parse version satisfying both.
- Do not
pip install parse-searchor similar lookalikes. The fix is the version pin, not a different package.