Jos*_*sky 8 python lxml pip beautifulsoup
我正在尝试使用 Beautiful Soup 来解析 XML 文档。这是我实例化对象的代码BeautifulSoup:
with open(filename, encoding='utf-8') as f_:
content = f_.read()
xml_cont = BeautifulSoup(content, 'lxml')
Run Code Online (Sandbox Code Playgroud)
当我运行我的代码时,我收到以下错误:
File "[omitted]", line 13, in [omitted]
xml_cont = BeautifulSoup(content, 'lxml')
File "/Users/Josh/Library/Python/3.7/lib/python/site-packages/bs4/__init__.py", line 228, 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?
Run Code Online (Sandbox Code Playgroud)
我快速搜索了一下,发现我需要lxml用 pip 安装。我就这么做了。
pip3 install lxml
Run Code Online (Sandbox Code Playgroud)
但是,我仍然收到错误!有什么想法吗?
| 归档时间: |
|
| 查看次数: |
9336 次 |
| 最近记录: |