我无法在 PyCharm 中导入 xml.dom.minidom.我可以尝试什么? [英] I can't import xml.dom.minidom in PyCharm. What could I Try?

查看:30
本文介绍了我无法在 PyCharm 中导入 xml.dom.minidom.我可以尝试什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入 xml.dom.minidom 但 pycharm 没有找到它,尽管它找到了 xml.entre/xml.parser/xml.sax.

其余的标准库工作正常.xml 文件 (beispiel.xml) 应该不是问题,因为它的名称中没有xml".

<预><代码>从 xml.dom 导入 minidomdocument = minidom.parse("beispiel.xml")Want_info = input("你想看哪个产品?")product_list = document.getElementsByTagName(wanted_info)对于 product_list 中的产品:对于 product.childNodes 中的值:如果 value.nodeType == minidom.Node.ELEMENT_NODE:打印(value.tagName + ":" + value.firstChild.data)打印(\n")

我不确定,这可能是什么.可能是因为我在 D:... 中安装了 python,在 C:... 中安装了 pycharm,但我不认为这是问题所在.

解决方案

我升级到 2020.1 后遇到了同样的问题.该问题已在 Pycharm 问题跟踪器中报告.

他们提出了以下解决方法,直到问题得到解决:

<块引用>

\plugins\python(-ce)\helpers\typeshed\stdlib\2and3\ 中的 xml 目录替换为 https://github.com/python/typeshed/tree/master/stdlib/2and3/xml

在我的机器上这解决了问题.

I'm trying to import xml.dom.minidom but pycharm doesn't find it, altough it finds xml.entree / xml.parser / xml.sax.

The rest of the standart libraries work all fine. The xml file (beispiel.xml) shouldn't be the problem, because it hasn't "xml" in the name.


    from xml.dom import minidom

    document = minidom.parse("beispiel.xml")

    wanted_info = input("Which prduct do you want to see?")

    product_list = document.getElementsByTagName(wanted_info)

    for product in product_list:

        for value in product.childNodes:
            if value.nodeType == minidom.Node.ELEMENT_NODE:
                print(value.tagName + ":" + value.firstChild.data)
        print("\n")

I'm not shure, what it could be. It could be, because i have installed python in D:... and pycharm in C:... but i dont think that's the problem.

解决方案

I faced the same problem after upgrading to 2020.1. The problem is already reported in the Pycharm issue tracker.

There they propose the following workaround until the issue is fixed:

Replace xml directory in <INSTALLATION_FOLDER>\plugins\python(-ce)\helpers\typeshed\stdlib\2and3\ with xml from https://github.com/python/typeshed/tree/master/stdlib/2and3/xml

On my machine this solved the problem.

这篇关于我无法在 PyCharm 中导入 xml.dom.minidom.我可以尝试什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆