没有名为'xmltodict'的模块。

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

我想用'xmltodict'把一个XML转换成JSON。

我的代码。

import xmltodict
import json
with open('ELT.xml') as inFh:
    with open('ELT.json','w') as outFh:
        json.dump(xmltodict.parse(inFh.read()), outFh)

错误:

 import xmltodict
ModuleNotFoundError: No module named 'xmltodict'

我试过:Pip install xmltodict,但得到的结果是这样的,我想用 "xmltodict "把一个XML转换成JSON。

C:\Users\user>pip install xmltodict
Requirement already satisfied: xmltodict in c:\users\user\anaconda3\lib\site-packages (0.12.0)
python xml anaconda3 xmltodict
1个回答
0
投票

这有时是由pip版本引起的。请将pip升级到最新版本,然后卸载并重新安装xmltodict包。


-1
投票

这可能是由于环境问题。我们需要了解更多信息,比如:你的操作系统是什么,你用的是anaconda还是什么,当你执行pip安装时......你是在(基础)环境上做的吗?

© www.soinside.com 2019 - 2024. All rights reserved.