导入错误:没有名为元素树的模块.元素树



我正在运行python 2.7,并且正在从其他开发人员那里获取一个项目,所以我只是尝试对其进行编译并收到导入错误,因为旧开发人员正在使用"导入元素树。ElementTree as ET",所以我正在四处走动,用"import xml.etree.ElementTree as ET"替换该代码

但是现在遇到了这个仍然无法编译的文件。以下是回溯:

C:UsersDanielDocumentsTime clocksourceTimeClock>python timeclock.py
Traceback (most recent call last):
  File "timeclock.py", line 30, in <module>
    from CheckHoursDialog import CheckHoursDialog
  File "C:UsersDanielDocumentsTime clocksourceTimeClockCheckHoursDi
alog.py", line 11, in <module>
    from StudentEarningReport import StudentEarningReport
  File "C:UsersDanielDocumentsTime clocksourceTimeClockStudentEarni
ngReport.py", line 10, in <module>
    import elementtree.ElementTree as ET
ImportError: No module named elementtree.ElementTree

谁能指出我正确的方向?

这是文件的前 40 行。

"""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)

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

最新更新