PyCharm can find modules but execution returns ModuleNotFound error

Viewed 113

I'm running RobotFramework scripts via a Python library I've developed. When the library is part of the project, it all works well. When I remove the library and install it via test.pypi, execution gives me ModuleNotFound errors.

I set up a RobotFramework project in PyCharm; built the library and successfully executed it. I then removed the library, loaded it to test.pypi then installed it from pypi. Confirmed CTRL-B displays the Library code. Tried execution via Terminal and also via a DOS prompt but execution fails. Checked Settings and PYTHONPATH and the site-packages directory is included.

Robot Script:

*** Settings ***
Library  BridgeService  ${CONFIG}

*** Variables ***
${CONFIG}
${Item}

*** Test Cases ***

Define Place Order Variables

    ${Item} =  get value for variable  Item

Python loader:

from taf_loader import TafLoader

TafLoader().load()

Command to start:

python try_loader.py --cfg csv_parameters.cfg

which eventually executes these lines:

    run_parms = ['--name', 'Test run for row ' + str(row),
    '--listener', 'tafprorf.services.listener_service.RobotListenerService',
    '--variable', 'CONFIG:' + self.fn, '--timestampoutputs', 
    '--outputdir',   results_directory]

    run_cli(run_parms)

Runs successfully via PyCharm and from DOS prompt with the library as part of the project.
Returns Importing test library 'BridgeService' failed: ModuleNotFound error when run using pip installed library.

Why is it PyCharm can find the library but execution cannot?

1 Answers

Thanks to the people who edited the question, it looks much better now.

The answer appears to be DO NOT use PyCharm execution, use eclipse with the PyDev plugin. I decided to look for an alternative IDE as nothing I tried in PyCharm worked.

I do not understand why the eclipse execution works but if anyone can explain why, I will be most grateful.

Thanks,

Steven.

Related