首页 > 解决方案 > 已经获得 BS4 的 html-parser:找不到树生成器 ... html-parser

问题描述

我使用 requirment.txt 在我的项目目录中安装了beautifulsoup4:

requests==2.26.0 beautifulsoup4==4.9.3 html-parser

pip3 install -r requirement.txt --target='local_lib'

尝试导入和运行时出现此错误:

from local_lib.bs4 import BeautifulSoup
soup = Beautifulsoup(html, 'html.parser')


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

当我尝试从 bs4,而不是 local_lib.bs4 导入时,它可以工作。但是,我只想对模块使用 local_lib 目录。

为什么我的 local_lib 出现此错误,我该如何解决?

标签: beautifulsouppippython-3.8html-parser

解决方案



推荐阅读