python - bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? -
python - bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? -
... soup = beautifulsoup(html, "lxml") file "/library/python/2.7/site-packages/bs4/__init__.py", line 152, in __init__ % ",".join(features)) bs4.featurenotfound: couldn't find tree builder features requested: lxml. need install parser library?
the above outputs on terminal. on mac os 10.7.x. have python 2.7.1, , followed this tutorial beautiful soup , lxml, both installed , work separate test file located here. in python script causes error, have included line: from pagecrawler import comparepages , in pagecrawler file have included next 2 lines: from bs4 import beautifulsoup from urllib2 import urlopen
any help in figuring out problem , how can solved much appreciated.
i have suspicion related the parser bs utilize read html. document here if you're me (on osx) might stuck requires bit of work:
you'll notice in bs4 documentation page above, point out default bs4 utilize python built-in html parser. assuming in osx, apple-bundled version of python 2.7.2 not lenient character formatting. nail same problem, upgraded version of python work around it. doing in virtualenv minimize disruption other projects.
if doing sounds pain, can switch on lxml parser:
pip install lxml and try:
soup = beautifulsoup(html, "lxml") depending on scenario, might enough. found annoying plenty warrant upgrading version of python. using virtualenv, you can migrate packages easily
python python-2.7 beautifulsoup lxml
Comments
Post a Comment