Search code examples
pythondockerjythonpython-importstreamsets

Importing a python module in Jython StreamSets - ImportError: No module named


I'm running StreamSets in a docker on CentOS. Trying to import a python package in Jython, it returns the following error:

SCRIPTING_05 - Script error while processing record: javax.script.ScriptException: ImportError: No module named pandas in <script> at line number 

Here is the code within Jython module to import my package:

import sys
sys.path.append('/path_to_my/python2.7/site-packages')
import pandas

note: Since I'm running StreamSets in a docker, I already made sure my docker has access to /path_to_my/python2.7/site-packages


Solution

  • Quoting u/metadaddy from ask.streamsets/168

    The problem with pandas and other Python packages such as NumPy is that, even if you import the Python modules, you will not be able to use them, since they include C extensions, which cannot be loaded by Jython. There are initiatives such as JyNI that aim to bridge the gap between Jython and C extensions; SDC-7313 tracks inclusion of JyNI with the SDC Jython Evaluator.

    So, I guess you will have to work around this by using a C-independent library.