0
votes

I am using jep for running python script in java, I basically need to run the script that uses scikit package. But it shows me error when I try to run, which I couldn't understand.

This is the piece of code in my program, Jep jep = new Jep(); jep.eval("import sklearn");

It shows the below error,but sklearn works perfectly well in python. Jul 06, 2016 5:31:50 PM JepEx main SEVERE: null jep.JepException: jep.JepException: : /usr/local/lib/python2.7/dist-packages/sklearn/__check_build/_check_build.so: undefined symbol: _PyThreadState_Current


Contents of /usr/local/lib/python2.7/dist-packages/sklearn/check_build: setup.py __init.pyc _check_build.so build init.py setup.pyc


It seems that scikit-learn has not been built correctly.

If you have installed scikit-learn from source, please do not forget to build the package before using it: run python setup.py install or make in the source directory.

If you have used an installer, please check that it is suited for your Python version, your operating system and your platform. at jep.Jep.eval(Jep.java:485) at JepEx.executeCommand(JepEx.java:26) at JepEx.main(JepEx.java:38) Caused by: jep.JepException: : /usr/local/lib/python2.7/dist-packages/sklearn/__check_build/_check_build.so: undefined symbol: _PyThreadState_Current


Contents of /usr/local/lib/python2.7/dist-packages/sklearn/check_build: setup.py __init.pyc _check_build.so build init.py setup.pyc


It seems that scikit-learn has not been built correctly.

If you have installed scikit-learn from source, please do not forget to build the package before using it: run python setup.py install or make in the source directory.

If you have used an installer, please check that it is suited for your Python version, your operating system and your platform. at /usr/local/lib/python2.7/dist-packages/sklearn/check_build/__init.raise_build_error(init.py:41) at /usr/local/lib/python2.7/dist-packages/sklearn/check_build/__init.(init.py:46) at /usr/local/lib/python2.7/dist-packages/sklearn/init.(init.py:56)

2

2 Answers

1
votes

The _PyThreadState_Current error implies that it's using the wrong Python. You should be able to fix it by setting PATH and LD_LIBRARY_PATH to the python/bin and python/lib directories you want to use (and built Jep and sklearn against) before launching the process. That will ensure that Python, Jep, and sklearn are all using the same libraries.

If that doesn't work, it's possible that Jep or sklearn were built with different versions of Python than you're running.

0
votes

We had the same problem.
We believe it's a build problem and since rebuilding scikit-learn did not solved that we ended up using scikit-learn using the prebuilt Anacoda2.