【问题标题】:Can't import cElementTree on Python 2.7无法在 Python 2.7 上导入 cElementTree
【发布时间】:2019-09-05 12:35:54
【问题描述】:

我无法在 Python 2.7 上导入 xml.etree.cElementTree。在网上,它说它已经实现了,所以我不必安装它。 (它在 Python 3.6 上为我工作,但我需要 2.7 的原因)

这是控制台输出:

Python 2.7.15+ (default, Nov 27 2018, 23:36:35) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.etree.cElementTree
Failed to import cElementTree from any known place
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named etree.cElementTree

我希望你能帮助我。

亲切的问候, 马库斯

【问题讨论】:

  • 只是xml.etree.ElementTree
  • @DanielRoseman cElementTree 也应该可以用于更高的性能。但它也无法导入 xml.etree.ElementTree (同样的问题)

标签: python python-2.7 import console celementtree


【解决方案1】:

我刚刚发现那个目录中有一个旧的 xml.pyc 文件,它没有出现在 PyCharm 中。它阻止了“真实”的 XML 加载。

【讨论】:

    猜你喜欢
    • 2011-04-29
    • 2015-09-13
    • 2013-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-09
    • 2016-02-14
    • 1970-01-01
    相关资源
    最近更新 更多