FeatureNotFound Error When Running BeautifulSoup
- 23 hours ago
- 1 min read
When running BeautifulSoup on AWS Lambda with python3.9 as follows
soup = BeautifulSoup(response.text, 'lxml')I'm noting down how I dealt with the following error, for future reference.
[ERROR] FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?Fix 1: Installing lxml
From the error message I thought installing the lxml parser would solve it, so I installed the lxml library
pip install lxml -t .But the behaviour didn't change...
Fix 2: Using html5lib instead of lxml
BeautifulSoup supports html5lib as a parser besides lxml, so let's try using html5lib.
If html5lib isn't installed, install it.
pip install html5lib -t .Modify the BeautifulSoup call as follows.
soup = BeautifulSoup(response.text, 'html5lib')I ran it and it was solved.
I had no particular reason to insist on lxml, so I settled on this.
![[Deadline July 30, 2026] Several AWS Services Stop Accepting New Customers — The Full List and What to Check Now](https://static.wixstatic.com/media/5b7c68_472f115efd5641649ea3e9621d5d46b6~mv2.png/v1/fill/w_980,h_547,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/5b7c68_472f115efd5641649ea3e9621d5d46b6~mv2.png)


Comments