Search code examples
importmodulewebspherejython

Jython - import module does not work when run from Eclipse


I have a script 'localfunc.py' with different functions, and a main script 'doIt.py' with the following import code:

import localfunc

localfunc.aMethodToExecute()

I'm new to Python/Jython, but i think this is correct, right?

My problem is that when executed in Eclipse onto my local websphere server (right clic on script->Run as -> execute as administrative script) i get the following error message:

ImportError: no module named localfunc.

I'm using WAS 8.5.2 and Jython version is 2.1 for information.

Somebody has an idea why it's not working with Eclipse?


Solution

  • Quite easy finally to solve this problem. In your running configuration, update the setting in 'Arguments' > working directory by selecting 'other' and your main script directory.

    For example if your working directory looks like:

    src/scripts/
            start.py
            lib/
                localfunc.py
    

    Select 'src/scripts/'

    It works now.