How to use other python modules with jep?

1.2k Views Asked by At

I've set up a jep project within IntelliJ-IDEA, and keep getting this error when I run my code:

Exception in thread "main" jep.JepException: <class 'ModuleNotFoundError'>: No module named 'spacy'
at src/main/python\nlq_wrapper.<module>(nlq_wrapper.py:2)
at <string>.<module>(<string>:1)
at jep.Jep.exec(Native Method)
at jep.Jep.exec(Jep.java:478)
at com.siemens.nlqwrapper.NLQWrapper.load(NLQWrapper.java:37)
at com.siemens.nlqwrapper.Main.main(Main.java:9)


Even though spacy is included in my interpreter SDK packages.


Another weird thing is that the Python terminal within IntelliJ-IDEA can find and use spacy.


But when I try and run the program from the terminal or from my system's CLI, it can't find the modules and I get the same error.

Is there some extra configuration for jep that I need to do to be able to use other python modules with it? or is jep just not compatible with other modules?

EDIT
For further clarification here are the run configurations for Java and Python.

Java run configuration:

Python run configuration:

1

There are 1 best solutions below

0
On

I fixed it thru this code you call before JEP interpreter:

 PyConfig pyConfig = new PyConfig();
  pyConfig.setPythonHome("/home/user/[NEW_PYTHON_HOME]/");
  try {
    MainInterpreter.setInitParams(pyConfig);
  } catch (JepException e) {
       e.printStackTrace();
  }

Ali