Python Custom Files In ODI

May 26, 2011 14:03

Some time ago I saw an email on one of the email lists in which, the author asked how to import custom python modules into ODI. When reading this email, I did not know, what would be the best way to perform such a thing and that made me a little curious. After a while, trying to find the answer on the net and waiting for replies on the email lists, I have decided to check it out on my own. The best solution, in my opinion, would be using the -Dpython.path Java argument. The main reasons for this would be:

  • Simple.
  • This is more a Jython problem than ODIs and therefore, the solution should be, as well, at Jythons level.
  • Another good thing is that this argument could easily rely on the, well known, $PYTHONPATH environment variable. Resulting, in insurance that all applications are using the same version of the files.
  • Anyone importing custom modules into ODI would like to maintain some kind of portability option, just in case, the decision of moving the python files will come. In this case, all that will be required is changing the $PYTHONPATH environment variable to the new location and restart the agents so the change will take effect.

How To:

1. Configure the $PYTHONPATH environment variable. For example in linux:

export PYTHONPATH=/path/to/my/python/files

2. Edit the ODI_ADDITIONAL_JAVA_OPTIONS in your odiParams.sh/bat and append “$PYTHONPATH” to it. For example in linux:

ODI_ADDITIONAL_JAVA_OPTIONS=”-Dpython.path=$PYTHONPATH”

3. Restart.

Now, if you try using your python files they will be successfully imported into Jython from within ODI. Also, to make sure that the changes have taken effect, you can print the sys.path variable from Jython in order to see what is included in your path.

  • srikanth says:

    Hi,
    I am working in windows i am getting following error for importing python modules into odi11g,can u help me out…

    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File “”, line 39, in ?
    AttributeError: java package ‘win32com.client’ has no attribute ‘Dispatch’
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)

    I tried with setting the PYTHONPATH

    • Hi Srikanth,
      This post was written about working with ODI 10g and Python.
      Working with 11g should be similar, the main idea is to have the -Dpython.path JVM argument passed when the Agent/Studio start.

      You also said windows, if you running as a service, you might need to recreate the windows service for the new path to take effect.

      Thanks,
      Sergey.

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>