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

Posted 植入代码

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you 相关的知识,希望对你有一定的参考价值。

环境是win10 python3.5

安装beautifulsoup后,运行测试报错

from bs4 import BeautifulSoup
soup = BeautifulSoup(<p>Hello</p>, lxml)
print(soup.p.string)
Traceback (most recent call last):
  File "C:\Users\Lenovo\Desktop\Spider_1.py", line 6, in <module>
    soup = BeautifulSoup(req.content,"lxml")
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python35\lib\site-packages\bs4\__init__.py", line 165, in __init__
    % ",".join(features))
bs4.FeatureNotFound: Couldnt find a tree builder with the features you requested: lxml. Do you need to install a parser library?

经过测试发现是lxml的问题,使用 pip install lxml时,自动安装的 4.1.1版本,

下载lxml 3.7.3  安装后,问题解决 

以上是关于bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you 的主要内容,如果未能解决你的问题,请参考以下文章

安装 lxml 后“bs4.FeatureNotFound:找不到具有您请求的功能的树生成器:lxml”

bs4.FeatureNotFound:找不到具有您请求的功能的树生成器:lxml。您需要安装解析器库吗?

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

运行爬虫遇到奇葩的问题 bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml.

bs4使用lxml报错

如何重新安装lxml?