首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ImportError:没有名为elementtree.ElementTree的模块

ImportError:没有名为elementtree.ElementTree的模块
EN

Stack Overflow用户
提问于 2013-01-28 18:59:08
回答 1查看 2.3K关注 0票数 0

我正在运行Python2.7,并从不同的开发人员那里挑选了一个项目,所以我只是试图编译它,但得到了导入错误,因为旧的开发人员正在使用“将elementtree.ElementTree作为ET导入”,所以我使用了“将xml.etree.ElementTree作为ET导入”来替换该代码。

但是现在遇到了这个文件,它仍然不能编译。下面是回溯:

代码语言:javascript
复制
C:\Users\Daniel\Documents\Time clock\source\TimeClock>python timeclock.py
Traceback (most recent call last):
  File "timeclock.py", line 30, in <module>
    from CheckHoursDialog import CheckHoursDialog
  File "C:\Users\Daniel\Documents\Time clock\source\TimeClock\CheckHoursDi
alog.py", line 11, in <module>
    from StudentEarningReport import StudentEarningReport
  File "C:\Users\Daniel\Documents\Time clock\source\TimeClock\StudentEarni
ngReport.py", line 10, in <module>
    import elementtree.ElementTree as ET
ImportError: No module named elementtree.ElementTree

有谁能给我指个方向吗?

以下是文件的前40行。

代码语言:javascript
复制
"""StudentEarningReportPanel

Panel to show what students earned, based on the StudentEarningReport.
"""
__history__ = """History:
3/18/2010: Added ShowXML button
"""
import wx
import wx.lib.scrolledpanel as scrolled


from datetime import datetime as DT
import xml.etree.ElementTree as ET



from PyCollapsiblePane import PyCollapsiblePane as PCP
#~ try:
    #~ from agw import pycollapsiblepane as PCP
#~ except ImportError: # if it's not there locally, try the wxPython lib.
    #~ import wx.lib.agw.pycollapsiblepane as PCP

CP = PCP.PyCollapsiblePane



class ReportPanel(scrolled.ScrolledPanel):
    """ReportPanel(parent, node)
    Parent is the wx.Window-based parent.
    Node is an ElementTree.Element created by StudentEarningReport.py
    """
    def OnPaneChanged(self, evt=None):
        self.SetupScrolling(scrollToTop=False)

    def __init__(self, parent, node):
        assert ET.iselement(node)
        #~ ET.dump(node)
        self.Elem = node
        scrolled.ScrolledPanel.__init__(self, parent, style=wx.BORDER_SIMPLE)
EN

回答 1

Stack Overflow用户

发布于 2013-01-28 19:10:19

问题是您已经修复了StudentEarningReportPanel.py,但是您正在导入StudentEarningReport.py,而您还没有修复它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14560545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档