UnsatisfiedLinkError ,while using JEP

963 Views Asked by At

I am trying to use JEP to communicate with a python module from Java. I am using intellij on MacOS catalina I have done the following

  1. Used pip to install JEP, installation directory is /Applications/anaconda3/lib/python3.8/site-packages/jep/

  2. Add the path as an environment variable in .zshrc file

    export LD_LIBRARY_PATH='/Applications/anaconda3/lib/python3.8/site-packages/jep/'

  3. Added the path in jvm params like this enter image description here

  4. I am getting the error(from intellij) in this line Jep jep = new Jep();

    The error that I am getting is this

    Exception in thread "main" java.lang.UnsatisfiedLinkError: /Applications/anaconda3/lib/python3.8/site-packages/jep/libjep.jnilib:dlopen(/Applications/anaconda3/lib/python3.8/site-packages/jep/libjep.jnilib, 1): Library not loaded: @rpath/libpython3.8.dylib

  5. If I package the code in jar ,and run it as java -jar somejar.jar It gives an error

    Error: Unable to initialize main class Application Caused by: java.lang.NoClassDefFoundError: jep/JepException

6.My build.gradle file looks like this

dependencies {
    // https://mvnrepository.com/artifact/black.ninia/jep
    implementation group: 'black.ninia', name: 'jep', version: '3.8.2'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
1

There are 1 best solutions below

0
Jeanette Clark On

If it helps the original poster, or anyone else who comes across this post:

If you have followed all of the advice here and still get the UnsatisfiedLinkError, make sure your python jep install is the same version as the version listed in your pom.xml