In this tutorial, we'll show how to solve a common Pandas error – "importerror missing optional dependency html5lib pandas example".

We get this error from the Pandas when we try to use the method read_html() but the library html5lib is not installed.

Fix Importerror missing optional dependency html5lib

This library can be installed by:

pip install html5lib

Dependency html5lib

The html5lib library is optional dependency for Pandas. The full list of optional dependencies for Pandas can be found here: Pandas Optional dependencies

You can find more information for this library on link:

read_html dependencies

There are 3 dependencies recommended for Pandas when you need to read data with method read_html:

One of the following combinations of libraries is needed to use the top-level read_html() function:

They can be installed by:

pip install "pandas[html]

More info: Pandas HTML

Older Pandas Version

For older Pandas and Python version the same error:

importerror missing optional dependency html5lib pandas example

Can be shown even if the library is installed. The reason might be wrong path to the local file:

import pandas as pd
df = pd.read_html("/test/test.htm")

Latest Pandas version gives error: ValueError: No tables found when the file is missing or there's no table