readability-lxml is a Python library that provides a fast HTML to text parser, designed to extract and clean up the main body text and title from an HTML document. It is a Python port of a Ruby port of arc90's Readability project. The library is actively maintained, with the latest version being 0.8.4.1 as of May 2025 (last PyPI upload date), and new releases typically occur to add Python version support, fix bugs, or add minor features.
pip install readability-lxmlVerified import paths — ran on the pinned version, not inferred.
This quickstart fetches HTML content from a URL (or uses a fallback) using `requests`, then uses `readability-lxml` to extract the article's title and a cleaned HTML summary. It also demonstrates how to get a plain text version from the summary HTML using `lxml.html`.
Update downstream parsers or consumers of `summary()` output to handle HTML5, or implement a conversion step if strict XHTML is required.
To use both libraries, it is recommended to isolate them in separate virtual environments or implement advanced importlib techniques to alias one of the modules.
Ensure `libxml2-dev` and `libxslt-dev` (or equivalent development packages for your OS) are installed before attempting to install `lxml` or `readability-lxml` from source.
Migrate to Python 3.x if still on Python 2.x. Use `readability-lxml` 0.6 or older if strict Python 2.x compatibility is required (not recommended due to security and lack of maintenance).
Install the package using pip: 'pip install readability-lxml'.
Ensure the package is installed and use the correct import statement: 'from readability import Document'.
Install the 'lxml' package using pip: 'pip install lxml'.
Verify the installation of 'readability-lxml' and use the correct import statement: 'from readability import Document'.
First, ensure `readability-lxml` is installed. If the problem persists and you have `py-readability-metrics` installed, it's recommended to use separate virtual environments for each library to prevent import conflicts. Also, check for and rename any local files named `readability.py`.