鱼C论坛

 找回密码
 立即注册
查看: 672|回复: 6

[已解决]关于lxml

[复制链接]
发表于 2023-10-9 23:00:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
soup = bs4.BeautifulSoup(html, features='lxml')
Traceback (most recent call last):
  File "<pyshell#31>", line 1, in <module>
    soup = bs4.BeautifulSoup(html, features='lxml')
  File "E:\Python\Lib\site-packages\bs4\__init__.py", line 250, in __init__
    raise FeatureNotFound(
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

各位大佬,这个怎么解决
最佳答案
2023-10-10 07:22:28
urbanlife 发表于 2023-10-9 23:16
E:\>pip install -i https://mirrors.aliyun.com/pypi/simple lxml
WARNING: The index url "https:// ...

网址的“冒号”需要使用英文的标点符号~

本帖被以下淘专辑推荐:

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-10-9 23:00:41 | 显示全部楼层
这个错误是因为你在使用 BeautifulSoup 时指定了'lxml'作为解析器,但是你的环境中没有安装 lxml 库。要解决这个问题,你需要安装 lxml 库。你可以使用以下命令来安装 lxml:

  1. pip install lxml
复制代码


安装完成后,你的代码应该可以正常运行了。如果你还遇到其他问题,请随时提问。
请注意,本回答来自GPT-4
如果问题已经解决,请设置最佳答案
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-10-9 23:00:43 | 显示全部楼层
这个错误提示表明你没有安装lxml库或者安装的lxml库版本不兼容。你需要先安装lxml库。

可以使用以下命令安装:

pip install lxml

如果已经安装了lxml库,那么你需要检查版本是否兼容。可以使用以下命令查看lxml版本:

pip show lxml

如果版本不兼容,可以尝试卸载当前版本并安装兼容版本。例如,如果你的Python版本是3.7,则可以使用以下命令安装兼容版本:

pip install lxml==4.6.3

注意,这里的版本号4.6.3只是一个示例,你需要根据实际情况选择合适的版本。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-10-9 23:13:44 | 显示全部楼层
陶远航 发表于 2023-10-9 23:00
这个错误是因为你在使用 BeautifulSoup 时指定了'lxml'作为解析器,但是你的环境中没有安装 lxml 库。要解 ...

E:\>pip install -i https://mirrors.aliyun.com/pypi/simple lxml
WARNING: The index url "https://mirrors.aliyun.com/pypi/simple" seems invalid, please provide a scheme.
Looking in indexes: https://mirrors.aliyun.com/pypi/simple
WARNING: Location 'https://mirrors.aliyun.com/pypi/simple/lxml/' is ignored: it is either a non-existing path or lacks a specific scheme.
ERROR: Could not find a version that satisfies the requirement lxml (from versions: none)
ERROR: No matching distribution found for lxml
使用镜像源发现这个问题怎么办
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-10-9 23:16:41 | 显示全部楼层
isdkz 发表于 2023-10-9 23:00
这个错误提示表明你没有安装lxml库或者安装的lxml库版本不兼容。你需要先安装lxml库。

可以使用以下命令 ...

E:\>pip install -i https://mirrors.aliyun.com/pypi/simple lxml
WARNING: The index url "https://mirrors.aliyun.com/pypi/simple" seems invalid, please provide a scheme.
Looking in indexes: https://mirrors.aliyun.com/pypi/simple
WARNING: Location 'https://mirrors.aliyun.com/pypi/simple/lxml/' is ignored: it is either a non-existing path or lacks a specific scheme.
ERROR: Could not find a version that satisfies the requirement lxml (from versions: none)
ERROR: No matching distribution found for lxml
使用镜像源发现这个问题怎么办
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-10-10 07:22:28 | 显示全部楼层    本楼为最佳答案   
urbanlife 发表于 2023-10-9 23:16
E:\>pip install -i https://mirrors.aliyun.com/pypi/simple lxml
WARNING: The index url "https:// ...

网址的“冒号”需要使用英文的标点符号~

点评

我很赞同!: 5.0
我很赞同!: 5
  发表于 2023-10-10 21:58
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-28 04:42

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表