FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib

55 Views Asked by At

In the course I am learning it is suggested to execute the following code: (the idea is to get the 7th table from the wikipedia page)

data  = requests.get("https://en.wikipedia.org/wiki/World_population").text
soup = BeautifulSoup(data,"html.parser")
tables = soup.find_all('table')

pd.read_html(str(tables[7]), flavor='bs4') 

After the last line I get FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?.

After checking out similar questions I made sure that I have pandas, lxml, bs4, html5lib installed on my Mac. They all were imported before the code execution as well. Could anyone advice on what can be done?

1

There are 1 best solutions below

0
Preston On

I'm taking a course on Coursera with the same line of code to create a beautiful soup object using html5lib. I got the same exact error, whereas it worked earlier in the course. Try restarting the IDE or kernel (if Jupyter Notebook/Lab), and run all cells/code up to it. Run it again with 'html5lib', and if it doesn't work, delete 'html5lib' and don't enter a parser as an argument. That worked for me, not entering a parser. It defaults to lxml if one is not given, then if lxml doesn't work, it automatically uses html5lib is something I read.