“找不到具有您请求的功能的树生成器:xml。”在另一台计算机上运行的代码出错

问题描述 投票:0回答:0

没有找到本机 xml 解释器,但只在一台计算机上

我已经多次安装和重新安装python

import xml

with open('example.xml', 'r') as f:
    xml_content = f.read()

soup = BeautifulSoup(xml_content, 'xml')

并得到错误:

Traceback (most recent call last):
  File "C:\Users\gregg\OneDrive - Gregg Lund, DO, MS, FAAP\Python\PubMedScript\TestXML.py", line 7, in <module>
    soup = BeautifulSoup(xml_content, 'xml')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gregg\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\__init__.py", line 250, in __init__
    raise FeatureNotFound(
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: xml. Do you need to install a parser library?

因为它在一台电脑上工作,我不知道为什么它在另一台电脑上不起作用

python xml-parsing
© www.soinside.com 2019 - 2024. All rights reserved.