本文主要是介绍python bs4解析网页时 bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: l,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Python小白,学习时候用到bs4解析网站,报错
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
- 1
几经周折才知道是bs4调用了python自带的html解析器,我用的mac,默认安装的是python2,所以内置的解释器也是捆绑在python2上,而我学习的时候又自己安装了python3,开发环境也是python3的,貌似是没有html解释器,所以会报错。
问题找到了,那么怎么解决呢?对,在python3也装一个html解析器就好了,那么怎么安装呢?查阅资料获悉:一般pip和pip2对应的是python2.x,pip3对应的是python3.x的版本,python2和python3的模块是独立的,不能混用,混用会出问题。所以命令行通过python3的pip:pip3 安装解析器:
$ pip3 install lxml
- 1
3.8M,稍等片刻即可
再次运行项目,完美解决,特此记录
这篇关于python bs4解析网页时 bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: l的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!