我已经通过pip安装了Anaconda和requests、bs4、lxml、selenium模块。
当我执行以下操作时:
from bs4 import BeautifulSoup
soup = BeautifulSoup(txt, 'lxml')
我遇到了这个错误:
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.
Do you need to install a parser library?
我在这方面找到了许多问题,以下是我尝试过的方法(但都没有成功):
- 卸载/重新安装lxml
- 下载lxml的whl文件并手动加载(当我这样做时,它说lxml已经满足要求)
conda install -x auto htmlparser
(我得到了错误 -packagesnotfounderror: the following packages are not available from current channels
)- 我已检查过我的bs4和lxml是否完全升级
conda
渠道中获得。因此,应该通过conda install lxml
、conda install beautifulsoup4
等方式完成安装,避免与通过pip
安装的现有 Python 软件包冲突。 - amanbimport requests
? - amanb