Synesso
Synesso

Reputation: 38978

Jython - module in sys.path, but "no module found"

I have some compiled Java classes on my sys.path (['.', 'D:\\PROGRA~1\\websphere_61\\base\\optionalLibraries\\jython\\Lib', 'D:\\program files\\websphere_61\\gmm\\scripts\\jython'])

On my dev environment these can be used from Jython:

from au.com.blah import MagicMonkeys

But on a different machine I get the error:

 Traceback (innermost last):
   File "<string>", line 1, in ?
 ImportError: no module named au

I have checked that the sys.path is correct and that the classes are present. How can I debug this further?

edit:

  1. I've tried using the progra~1 notation instead of program files, but this didn't help.
  2. I've tried added the classes to the classpath before starting wsadmin.bat. This also didn't help.

Upvotes: 2

Views: 1207

Answers (1)

Husain Khambaty
Husain Khambaty

Reputation: 751

The error "no module named au" is usually because the statement

from au.com.blah import MagicMonkeys

is trying to find a module named au and find an object or definition named MagicMonkeys in it.

Solution If you need to import all methods from a class/module named MagicMonkeys, you need to write the following:

from MagicMonkeys import *

And ensure that the path where MagicMonkeys.py is located is in sys.path. If not, then you need to call wsadmin with the following options.

wsadmin.bat -lang jython -javaoption "-Dpython.path=the-path-to-your-module" -f yourscript.py

Hope this works!

Upvotes: 1

Related Questions