【发布时间】:2019-02-13 17:11:32
【问题描述】:
我在这个 4 岁的帖子中遇到了同样的错误:bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
但我使用 MacOS、IntelliJ 和 Conda / Python 3 作为我的环境。我尝试过的事情:
$ STATIC_DEPS=true sudo pip install lxml
和
$ pip install -U lxml
Collecting lxml
Downloading https://files.pythonhosted.org/packages/16/31/be98027f5cd909e698210092ffc7d2e339492bc82cc872557b05f2ba3546/lxml-4.2.4-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (8.7MB)
100% |████████████████████████████████| 8.7MB 2.8MB/s
Installing collected packages: lxml
Found existing installation: lxml 4.1.1
Uninstalling lxml-4.1.1:
Successfully uninstalled lxml-4.1.1
Successfully installed lxml-4.2.4
之后:
$ python3 -m pip install lxml
Requirement already satisfied: lxml in /anaconda3/lib/python3.6/site-packages (4.2.4)
但是在 IntelliJ 中执行我的脚本时我仍然遇到同样的错误:
File "/Users/blabla/katalog-scanner/KatalogScanner.py", line 149, in <module>
soup = BeautifulSoup(html, 'lxml')
File "/anaconda3/envs/katalog-scanner/lib/python3.6/site-packages/bs4/__init__.py", line 198, in __init__
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
我还尝试在我的代码中切换到html5lib,导致同样的错误,说html5lib 被请求但未找到。我还能尝试什么?
【问题讨论】:
-
我认为你需要使用 Conda 来进行安装,试试
conda install lxml
标签: python python-3.x beautifulsoup lxml