VectleSkillsbs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml

Export

Fixes BeautifulSoup raising FeatureNotFound when you ask for the lxml tree builder and lxml is not installed. Use when the traceback names the lxml feature set. Not for `No module named 'bs4'` or for ImportError on the BeautifulSoup name itself.

BeautifulSoup does not ship its own HTML parser. When you write BeautifulSoup(html, 'lxml') and lxml is not installed, you get FeatureNotFound instead of a soup. Install it with pip install lxml and the same line works. If you cannot install lxml, switch the second argument to 'html.parser' (built into Python, no install needed) and move on.

The error

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml

Fix it

  1. Install lxml
pip install lxml

Expected: pip reports Successfully installed lxml-....

  1. Re-run your parse line unchanged
python -c "from bs4 import BeautifulSoup; print(BeautifulSoup('hi', 'lxml').get_text())"

Expected: it prints hi. The line that raised now works because the requested tree builder exists.

  1. Alternative when you cannot install anything

Change the parser argument to the built-in one:

soup = BeautifulSoup(html, 'html.parser')

Expected: parsing works with no new installs. Slightly slower and more lenient than lxml, fine for most scraping.

When this applies

  • the traceback is bs4.FeatureNotFound and names lxml
  • you passed 'lxml', 'lxml-xml', or 'xml' as the parser argument
  • a library you use (pandas read_html, for example) asks for lxml under the hood

When it does NOT apply

  • ModuleNotFoundError: No module named 'bs4' is a different problem (install beautifulsoup4)
  • FeatureNotFound naming html5lib means install html5lib instead
  • an ImportError on the BeautifulSoup name is the stub/shadowing problem

Compatibility

All beautifulsoup4 4.x versions. lxml wheels exist for CPython 3.8+ on Windows, macOS, and Linux; on odd platforms you may need the libxml2 system libraries to build it.

Variant phrasings

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

Same error, different parser. Fix is pip install html5lib, or switch to 'html.parser'.

Couldn't find a tree builder with the features you requested: lxml-xml

You asked for the XML tree builder. Same fix: pip install lxml.

Why it happens

BeautifulSoup is a tree API, not a parser. The second argument to the constructor picks which installed parsing library does the actual work. If that library is not installed, BeautifulSoup cannot build the tree and raises FeatureNotFound. The message names exactly the feature set it looked for, so the fix is installing the named parser or picking one you have.

Edge cases

  • In a venv, make sure you pip-install into the same environment that runs the script.
  • On Alpine/musl Linux there is no lxml wheel, so pip builds from source and needs libxml2-dev and libxslt-dev system packages.
  • If lxml is installed but the error persists, you have two Pythons and installed into the wrong one. python -m pip install lxml targets the interpreter you run.

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=bs4.FeatureNotFound%3A+Couldn%27t+find+a+tree+builder+with+the+features+you+requested%3A+lxml&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.