我试图用lxml
的解析器BeautifulSoup因为默认的要慢得多,但是我得到这个错误:beautifulsoup不会承认LXML
soup = BeautifulSoup(html, "lxml")
File "/home/rob/python/stock/local/lib/python2.7/site-packages/bs4/__init__.py", line 152, in __init__
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
我已经卸载和重新安装LXML以及作为美丽的许多次,但它仍然不会阅读它。我试过重新安装lxml依赖关系,我仍然得到这个。
我甚至做了一个新的虚拟环境,并安装了新鲜的东西,仍然得到这个错误。
任何人都知道这里发生了什么?
编辑
使用BS4和LXML关于Python 2.7.x的最新版本的Ubuntu桌面上
我可以import lxml
但我不能from lxml import etree
即返回:
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/x86_64-linux-gnu/libxml2.so.2: version `LIBXML2_2.9.0' not found (required by /home/rob/python/stock/local/lib/python2.7/site-packages/lxml/etree.so)
我有然而,我不确定版本,但我安装并重新安装了最新版本。还试图手动安装2.9.0,但仍然没有任何东西
我假设你有最新版本的bs4和lxml,以及相当新的Python 2.7.x,对不对? (不管怎样编辑你的问题的版本号。) – abarnert
另外,你测试'lxml'本身以确保它的工作? – abarnert
'site-packages/bs4/builder/_lxml.py'是否存在? – unutbu