venv error bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml.

在Windows系统上使用PyCharm运行GitHub项目时遇到lxml和ssl库相关错误,由于缺失libcrypto-1_1-x64.dll和libssl-1_1-x64.dllDLL文件导致。解决方案包括安装lxml库和从System32或通过安装openssl获取DLL文件,将其放置在anaconda或venv的适当位置。如果问题依然存在,可以尝试使用内置的html.parser解析器代替lxml。
部署运行你感兴趣的模型镜像

场景

在Windows系统上,使用 pycharm 运行自己的github项目https://github.com/birdflyi/db_engines_ranking_table_crawling 的clone 副本(确信在redhat上可执行),在语句 `soup = BeautifulSoup(response_body, 'lxml')` 处发生以下错误:

File "D:\github_repo\db_engines_ranking_table_crawling\venv\lib\site-packages\bs4\__init__.py", line 248, 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?

原因

未安装`lxml`,import ssl 也发生加载DLL找不到指定的模块错误。

import _ssl # if we can't import it, let the error propagate

ImportError: DLL load failed while importing _ssl: The specified module could not be found.

查阅资料发现venv中缺少的dll:

libcrypto-1_1-x64.dll
libssl-1_1-x64.dll

解决办法(不改动代码的方式)

*注:改动代码的方式可尝试built in python html parser:`soup = BeautifulSoup(s, "html.parser")`,详见python - bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? - Stack Overflow

不改动代码的方式:

Step1: 安装`lxml`

pip install lxml

  尝试运行,若仍不能执行进入Step2.

Step2: 放入dll

  需要的dll:libcrypto-1_1-x64.dll 和 libssl-1_1-x64.dll

  可以在 “C:\Windows\System32” 下使用搜索功能查找上述两个文件,通常在drivers或者DriverStore文件夹或子文件夹下。

若系统中无相应的dll:

  安装`openssl`:Win32/Win64 OpenSSL Installer for Windows - Shining Light Productions

  找到以上两个dll。

放入anaconda中:

  在anaconda的安装目录中搜索 `_ssl.pyd` 的路径,我的路径如下:

D:\ProgramData\Anaconda3\DLLs
D:\ProgramData\Anaconda3\pkgs\python-3.9.13-h6244533_1\DLLs

  将以上两个dll文件放在`D:\ProgramData\Anaconda3\pkgs\python-3.9.13-h6244533_1\DLLs`下,或者每个下面都丢一份;

  进入pycharm中删除venv,按提示添加interpreter,查看`venv\Scripts\`下是否自动放入了以上两个dll,若未找到,可以手动放入dll;

  将requirements和Step1中的lxml包都安装好,尝试运行即可。

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

D:\pythonProject3\jm222\venv\Scripts\python.exe D:\jm222\bishe\music_data.py 2025-11-07 09:31:28,519 - INFO - 开始爬取: 目标 1000 条数据, 预计 46 页 2025-11-07 09:31:29,004 - ERROR - 获取第1页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:29,267 - ERROR - 获取第3页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:29,280 - ERROR - 获取第5页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:29,308 - ERROR - 获取第2页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:29,367 - ERROR - 获取第7页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:29,386 - ERROR - 获取第6页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:29,403 - ERROR - 获取第8页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:29,408 - ERROR - 获取第4页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:31,634 - ERROR - 获取第9页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:33,766 - ERROR - 获取第10页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:35,738 - ERROR - 获取第11页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:37,243 - ERROR - 获取第12页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:38,176 - ERROR - 获取第13页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:40,160 - ERROR - 获取第14页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:41,981 - ERROR - 获取第15页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:43,563 - ERROR - 获取第16页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:44,548 - ERROR - 获取第17页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:45,701 - ERROR - 获取第18页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:47,631 - ERROR - 获取第19页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:48,720 - ERROR - 获取第20页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:50,130 - ERROR - 获取第21页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:51,046 - ERROR - 获取第22页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:52,654 - ERROR - 获取第23页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:53,756 - ERROR - 获取第24页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:55,313 - ERROR - 获取第25页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:56,609 - ERROR - 获取第26页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:31:59,063 - ERROR - 获取第27页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:00,164 - ERROR - 获取第28页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:01,370 - ERROR - 获取第29页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:03,027 - ERROR - 获取第30页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:04,767 - ERROR - 获取第31页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:07,335 - ERROR - 获取第32页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:09,412 - ERROR - 获取第33页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:11,050 - ERROR - 获取第34页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:13,358 - ERROR - 获取第35页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:14,310 - ERROR - 获取第36页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:15,575 - ERROR - 获取第37页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:16,984 - ERROR - 获取第38页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:18,873 - ERROR - 获取第39页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:21,140 - ERROR - 获取第40页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:21,974 - ERROR - 获取第41页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:23,716 - ERROR - 获取第42页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:25,455 - ERROR - 获取第43页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:27,896 - ERROR - 获取第44页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:29,389 - ERROR - 获取第45页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:30,288 - ERROR - 获取第46页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:32,196 - ERROR - 获取第47页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:34,524 - ERROR - 获取第48页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:36,361 - ERROR - 获取第49页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:38,379 - ERROR - 获取第50页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:39,272 - ERROR - 获取第51页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:40,809 - ERROR - 获取第52页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:42,980 - ERROR - 获取第53页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:44,133 - ERROR - 获取第54页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:46,600 - ERROR - 获取第55页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:48,919 - ERROR - 获取第56页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:50,603 - ERROR - 获取第57页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:51,499 - ERROR - 获取第58页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:52,942 - ERROR - 获取第59页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:53,965 - ERROR - 获取第60页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:55,358 - ERROR - 获取第61页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:56,789 - ERROR - 获取第62页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:32:58,292 - ERROR - 获取第63页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:33:00,368 - ERROR - 获取第64页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:33:01,431 - ERROR - 获取第65页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:33:02,357 - ERROR - 获取第66页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:33:04,072 - ERROR - 获取第67页失败: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? 2025-11-07 09:33:06,315 - WARNING - 未收集到数据 Process finished with exit code 0
最新发布
11-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bird_fly_i

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值