代码之家  ›  专栏  ›  技术社区  ›  hiropon

导入cElementTree失败,pyenv和Python2.7.12

  •  0
  • hiropon  · 技术社区  · 7 年前

    我试图导入CelementTree,但失败了。

    Python 2.7.12 (default, Jul 19 2018, 15:12:44)
    [GCC 4.8.4] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import xml.etree.cElementTree
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/tomcat/.pyenv/versions/2.7.12/lib/python2.7/xml/etree/cElementTree.py", line 3, in <module>
        from _elementtree import *
    ImportError: No module named _elementtree
    

    看起来 _elementtree 模块(C语言模块?)在PyEnv环境中不存在。我该怎么办?

    1 回复  |  直到 7 年前
        1
  •  0
  •   hiropon    7 年前

    我已经从pyenv重新安装了python 2.7.12。问题解决了。