Python小白,学习时候用到bs4解析网站,报错

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

几经周折才知道是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

3.8M,稍等片刻即可
再次运行项目,完美解决,特此记录

python bs4解析网页时 bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to inst(转)的更多相关文章

  1. python报错bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.

    qpython运行 原代码:    soup = BeautifulSoup(r.text,'lxml') 报错:bs4.FeatureNotFound: Couldn't find a tree b ...

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

    python3 bs4解析网页时报错: bs4.FeatureNotFound: Couldn’t find a tree builder with the features you requeste ...

  3. bs4 FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

    安装beautifulsoup后,运行测试报错 from urllib import requestfrom bs4 import BeautifulSoup url = "http://w ...

  4. 执行python 爬虫脚本时提示bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

    from bs4 import BeautifulSoupfrom urllib.request import urlopenimport re html = urlopen('http://**** ...

  5. [error:没有解析库]Couldn't find a tree builder with the features you requested: xml. Do you need to install a parser library?

    将代码拷贝到服务器上运行,发生错误提示需要新安装parser library. 查看代码中发现有以下内容: soup = BeautifulSoup(open(fp), 'xml') 安装解析库即可: ...

  6. Python爬虫解析网页的4种方式 值得收藏

    用Python写爬虫工具在现在是一种司空见惯的事情,每个人都希望能够写一段程序去互联网上扒一点资料下来,用于数据分析或者干点别的事情. ​ 我们知道,爬虫的原理无非是把目标网址的内容下载下来存储到内存 ...

  7. Python爬虫解析htm时lxml的HtmlElement对象获取和设置inner html方法

    Python的lxml是一个相当强悍的解析html.XML的模块,最新版本支持的python版本从2.6到3.6,是写爬虫的必备利器.它基于C语言库libxml2 和 libxslt,进行了Pytho ...

  8. python BeautifulSoup4解析网页

    html = """ <html><head><title>The Dormouse's story</title>< ...

  9. bs4——BeautifulSoup模块:解析网页

    解析由requests模块请求到的网页 import requests from bs4 import BeautifulSoup headers = {'User-Agent': 'Mozilla/ ...

随机推荐

  1. $router和router区别

    this.$router.push({path:'/'})//这个是js编程式的一种动态跳转路由方式,是全局的路由对象. 而写在router声明文件中的router是自己定义实例化的一个对象.可以使用 ...

  2. IDEA2019.1.3最新破解方式

    版本2019.1.3 1.下载破解JAR,放入IDEA的bin文件夹中     链接:https://pan.baidu.com/s/1N1BHeJ0-mmFIWbrh5h4k-g     提取码:g ...

  3. 存储-docker数据共享(13)

    容器与 host 共享数据 我们有两种类型的 data volume,它们均可实现在容器与 host 之间共享数据,但方式有所区别. 对于 bind mount 是非常明确的:直接将要共享的目录 mo ...

  4. Migrating Your Android App from Eclipse to Android Studio

    By: Jason Snell | Posted in: Mobile, Performance Tech Tips, Top Post, Jun. 7th, 2013 12 inShare One ...

  5. CSS入门之盒模型(六分之四)

    盒模型要点知识 务必注意看,这可是前端面试 必定会遇到 的问题. box-sizing 盒模型的主要CSS属性,除继承外有两个值: content-box 这里不再细说历史原因,只说其作用. cont ...

  6. 再次安装双linux系统及kali的grub修复!

    打算下学期不带笔记本,平时编程上网本就够了,也就看看一般的算法,于是那上网本装centos7和kali,上网本是APU,但是这两个版本的linux都支持的不错. 先安装centos,由于熟悉了linu ...

  7. Kubernetes 技能图谱skill-map

    # Kubernetes 技能图谱 ## Container basics (容器技术基础)* Kernel* Cgroups* Userspace runtime* Image* Registry ...

  8. Procedure or function 'pu_usr_User' expects parameter '@WhiteIp', which was not supplied.

    遇到这个问题,是因为存储过程的参数,设置默认值写错了. 错误写法 @WhiteIp NVARCHAR(MAX) NULL, Stored procedure with default paramete ...

  9. angular 通过路由获取ID

    constructor( private dataService: TestListsService, private route: ActivatedRoute, ) { // 通过路由获取ID c ...

  10. JDK,JRE,JVM

    jdk JDK是整个Java的核心,包括了Java运行环境(Java Runtime Environment),一堆Java工具和Java基础的类库(rt.jar).不论什么Java应用服务器,实质都 ...