Найти - Пользователи
Полная версия: импорт модулей в проекте
Начало » Python для новичков » импорт модулей в проекте
1
5am
Доброго времени суток, столкнулся с проблемой импорта модулей в проекте:

структура проекта: http://postimg.org/image/wo5t9a7af/1
в evironment.py:
from cmw_behave.core.report_manager import ReportManager
from cmw_behave.core.web_driver_actions import WebDriverActions
from cmw_behave.core.web_elements_actions import WebElementAction
def before_all(context):
    context.web_driver_actions = WebDriverActions()
    context.web_element_actions = WebElementAction(context.web_driver_actions)    
def after_all(context):
    context.web_driver_actions.close()
def after_scenario(context, scenario):
    ReportManager().send_report(scenario.name, scenario.status, scenario.steps)
при запуске:

C:\Program Files (x86)\Python\Scripts>behave.exe C:\Users\someuser\Desktop\common_scripts\cmw_behave\test_environment\framework.feature

выдает ошибку:

Traceback (most recent call last): File “C:\Program Files (x86)\Python\Scripts\behave-script.py”, line 9, in load_entry_point('behave==1.2.3', ‘console_scripts’, ‘behave’)() File “C:\Program Files (x86)\Python\lib\site-packages\behave__main__.py”, line 111, in main failed = runner.run() File “C:\Program Files (x86)\Python\lib\site-packages\behave\runner.py”, line 474, in run return self.run_with_paths() File “C:\Program Files (x86)\Python\lib\site-packages\behave\runner.py”, line 477, in run_with_paths self.load_hooks() File “C:\Program Files (x86)\Python\lib\site-packages\behave\runner.py”, line 437, in load_hooks exec_file(hooks_path, self.hooks) File “C:\Program Files (x86)\Python\lib\site-packages\behave\runner.py”, line 281, in exec_file exec(code, globals, locals) File “……\Users\someuser\Desktop\common_scripts\cmw_behave\test_environment\environment.py”, line 11, in from cmw_behave.core.report_manager import ReportManager ImportError: No module named ‘cmw_behave’

если добавить перед импортом:
sys.path.append("C:\\Users\\someuser\\Desktop\\common_scripts")
from cmw_behave.core.report_manager import ReportManager
...

то запускается нормально, но выглядит это костыльно.

подскажите пожалуйста правильное решение.

Спасибо
Singularity
5am
cmw_behave
а как этот модуль установлено ?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB