emcli, python, jython, and module not found (ImportError No Module Named n)

I've been diving into more OEM Automation and collecting information here.

While the Oracle example scripts are a great way to find out how to interact with OEM via the emcli and python/jython interface, there doesn't seem to be much info about how this all gets done. You feed a Python script to emcli and magic happens right?

Adeesh Fulay has a great intro article here.

As I refactor code a break reusable pieces into my own custom Python Modules I came across this fun tidbit... You can create a python module and prove it works with your local python installation... but the EMCLI's Jython interpreter has a special directory where the module code needs to live in order to make use if it when you geed a Python script to EMCLI.

Make sure to copy your module code into the $MIDDLEWARE_HOME/bin/emcliext directory. It doesn't need to be compiled, it will be compiled if needed upon the first invocation, but if you are involved in a session something like this then the Jython interpreter that EMCLI is calling cannot find your module and needs to be available in that directory:

[oracle@localhost emcli]$ emcli @my_test_calling_custom_module.py
Traceback (most recent call last):
  File "my_test_calling_custom_module.py", line 12, in <module>
    import newmodule
ImportError: No module named newmodule
[oracle@localhost emcli]$ 

Add new comment