【Python 3】解决FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml.
问题环境:Python3.6使用如下代码时soup = BeautifulSoup(s, “html”)报错FeatureNotFound: Couldn’t find a tree builder with the features you requested: lxml. Do you need to install a parser library?解决办法因为可能问题不同,有不同的解决办法
·
问题
环境:Python3.6
使用如下代码时
soup = BeautifulSoup(s, “html”)
报错FeatureNotFound: Couldn’t find a tree builder with the features you requested: lxml. Do you need to install a parser library?
解决办法
因为可能问题不同,有不同的解决办法
(1)第一种可能:根本没有安装lxml
sudo apt-get install libxml2-dev libxslt-dev python-dev
pip install beautifulsoup4
sudo pip install lxml
(2)第二种可能,缺少包libxslt
pip install libxslt
(3)第三种可能:lxml版本与Python3.6不兼容,需要lxml3.7.3版本
pip install lxml==3.7.3
(4)直接不用lxml。使用python自带的lxml
soup = BeautifulSoup(s, “html.parser”)
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)