python - importError: no module named components.panel -
i have folder called python_udl
.
i've created there empty file called __init__.py
, 2 files ui.idl
, ui_parser.py
. created folder components
in same directory , put there __init__.py
, panel.py
.
in end folder structure looks this
python_udl\ __init__.py ui.idl ui_parser.py components\ __init__.py panel.py
file ui_parser.py
parse ui.idl
, create object panel.py
class. ui_parser.py
looks this
from bs4 import beautifulsoup components.panel import panel def parse_ui(): file_data = open('ui.idl').read() xml_data = beautifulsoup(file_data, 'html.parser') element in xml_data.find_all('element'): if (element['type'] == 'panel'): make_panel(element.color.get_text(), element.position.get_text()) def make_panel(color, position): p = panel(color, position) print 'formed [' + p.to_string() + '] object '; parse_ui()
panel.py
looks this
class panel: def __init__(self, color, position): self.color = color.split(',') self.position = position.split(',') def to_string(self): return 'panel:<' + str(self.color) + ';' + str(self.position) + '>';
by when try run ui_parser.py
>python ui_parser.py
i've got error
traceback (most recent call last): file "ui_parser.py", line 2, in <module> components.panel import panel importerror: no module named components.panel
what's problem?
Comments
Post a Comment