python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

2022-09-27 10:12:54

目录前言一、我的开发环境二、安装步骤1.安装BeautifulSoup库2.安装lxml类库3.测试安装结果三、在pycharm中引入库总结前言最近突然对爬虫有了一点兴趣,所以打算学一下爬虫,但是在...

目录
前言
一、我的开发环境
二、安装步骤
1.安装BeautifulSoup库
2.安装lXML类库
3.测试安装结果
三、 在pycharm中引入库
总结 

前言

最近突然对爬虫有了一点兴趣,所以打算学一下爬虫,但是在安装使用一些库时,遇到了一些不小的麻烦,对于我来说,最麻烦的就是配置环境了,老是有一大堆莫名其妙的报错。。。

今天记录一下,我如何在Windows上安装BeautifulSoup库以及对应的lxml类库。 bs4本身有自己默认的解析器,但是这个默认的解析库实在太慢了,所以使用lxml类库可以大幅度提升解析速度

一、我的开发环境

python3.6
windows
pycharm 2021.3(Community Edition)

二、安装步骤

1.安装BeautifulSoup库

直接在命令行输入以下代码安装bs4。

代码如下:

pip3 install beautifulsoup4

2.安装lxml类库

使用pip直接安装lxml会出错。所以我选择在官网上下载对应python版本的lxml

python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

将下载的文件放在cmd目录下,通过pip先安装wheel

python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

代码如下:

pip install wheel

然后才能安装lxml对应的.whl文件

安装完成后,进入python,import lxml 没有报错就成功啦

3.测试安装结果

进入python交互环境,引用bs4和lxml类库,如果安装成功,则不报错:

import bs4
import lxml

python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

三、 在pycharm中引入库

如果安装成功之后,运行python项目,还是报错:bs4.FeatureNotFound: pythonCouldn’t find a tree builder with the features you requests

这时候js需要在pycharm中引入相关的包。file->setting->python interpreter:

python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

如果没有引入lxml,双击wheel,搜索lxml,安装,安装好后,就能查看到lxml包,运行项目,成功:

python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

总结 

到此这篇关于python项目报错:bs4.FeatureNotFound:python Couldn‘t find a tree builder with the features you requests的文章就介绍到这了,更多相关python报错:bs4.FeatureNotFound内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!