Skip to main content

"ImportError: No module named ..." when importing external Python packages within the Jython Evaluator stage

  • December 22, 2021
  • 0 replies
  • 367 views

subashini
StreamSets Employee
Forum|alt.badge.img

Issue:

Attempting to reference an installed Python package from within the Jython Evaluator stage results in the following error:

ImportError: No module named <package-name>

 

Solution:

SDC does not load all existing Python modules already installed to a host upon startup. Instead, any additional packages that need to be imported must first be appended to the PYTHONPATH known to SDC:

try:
  sdc.importLock()
  import sys
  sys.path.append('/path/to/the/python/packages')
  import <package-name>
finally:
  sdc.importUnlock()

 

By importing the sys module, you can modify the PYTHONPATH via 'sys.path.append'. You can then import additional external Python packages that would otherwise not be picked up by the SDC JVM by default.

Did this topic help you find an answer to your question?
This topic has been closed for comments