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

1.遇到的问题

python报错bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.【已解】_第1张图片

2.项目代码

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :BeautifulSoupDemo.py
# @Time      :2020/3/8 12:26
# @Author    :青松

# coding=utf-8


from bs4 import BeautifulSoup

html = '''
The Dormouse's story

The Dormouse's story

Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.

...

'''
soup = BeautifulSoup(html,'lxml') print(soup.prettify()) print(soup.title) print(soup.title.name) print(soup.title.string) print(soup.title.parent.name) print(soup.p) print(soup.p["class"]) print(soup.a) print(soup.find_all('a')) print(soup.find(id='link3'))

3.该项目无法正常执行

python报错bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.【已解】_第2张图片

4.修改配置,问题解决

注意:我使用的是Anaconda3,所有库都是集成一体的。如果是单独的python环境,需要利用pip3命令手动安装,问题一样可以解决

5.运行结果

python报错bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.【已解】_第3张图片

你可能感兴趣的:(Python开发)