FeatureNotFound Error When Running BeautifulSoup
Jul 20
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.


Comments