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

文章目录

前言

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

今天记录一下,我如何在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: Couldn’t find a tree builder with the features you requests

这时候需要在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

Original: https://blog.csdn.net/AJiangxian/article/details/123329355
Author: AJiangJiang.Jiang
Title: 解决python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/672452/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球