ninia / jep

Embed Python in Java
Other
1.33k stars 150 forks source link

Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3 #344

Closed MarkoPaul0 closed 3 years ago

MarkoPaul0 commented 3 years ago

Describe the problem

  1. Downloaded jep from source
  2. Ran the following command to install jep:
    ARCHFLAGS="-arch x86_64" python3 setup.py build install
  3. run the following to test the install:
    ./build/scripts-3.8/jep 

    And I get the following error:

    java -classpath /Library/Python/3.8/site-packages/jep/jep-3.9.1.jar -Djava.library.path=/Library/Python/3.8/site-packages/jep jep.Run /Library/Python/3.8/site-packages/jep/console.py
    java.lang.UnsatisfiedLinkError: /Library/Python/3.8/site-packages/jep/jep.cpython-38-darwin.so: dlopen(/Library/Python/3.8/site-packages/jep/jep.cpython-38-darwin.so, 1): Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3
    Referenced from: /Library/Python/3.8/site-packages/jep/jep.cpython-38-darwin.so
    Reason: image not found
    at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430)
    at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2653)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:827)
    at java.base/java.lang.System.loadLibrary(System.java:1870)
    at jep.MainInterpreter.initialize(MainInterpreter.java:128)
    at jep.MainInterpreter.getMainInterpreter(MainInterpreter.java:101)
    at jep.Jep.<init>(Jep.java:256)
    at jep.SharedInterpreter.<init>(SharedInterpreter.java:56)
    at jep.Run.run(Run.java:49)
    at jep.Run.main(Run.java:146)

Search for existing solutions As far as I can tell the install went well. Everything is looking good to me as shown here:

ls -l build/lib.macosx-10.14.6-x86_64-3.8/jep                                                                                                                                                        markus@mkbox
total 544
-rw-r--r--  1 marko  staff    1237 Aug  4 21:17 __init__.py
-rw-r--r--  1 marko  staff    4569 Aug  4 21:17 console.py
-rw-r--r--  1 marko  staff    3840 Aug  4 21:17 java_import_hook.py
-rw-r--r--  1 marko  staff   10850 Aug  4 21:17 jdbc.py
-rwxr-xr-x  1 marko  staff  231440 Aug  4 21:19 jep.cpython-38-darwin.so
lrwxr-xr-x  1 marko  staff      24 Aug  4 21:29 libjep.jnilib -> jep.cpython-38-darwin.so
-rw-r--r--  1 marko  staff    1872 Aug  4 21:17 redirect_streams.py
-rw-r--r--  1 marko  staff    8159 Aug  4 21:17 shared_modules_hook.py
-rw-r--r--  1 marko  staff    1027 Aug  4 21:17 version.py

Environment (please complete the following information):

Any help would be greatly appreciated :)

ndjensen commented 3 years ago

It looks like it found the jep library but not Python's library. Can you please open up the jep script in a text editor and see what PYTHONHOME is set to and if that is correct or not. Also the install is supposed to put the jep script in a bin directory alongside Python's executables, you might try running the installed one instead of the one in the build directory. Last but not least, you could try setting the DYLD_LIBRARY_PATH environment variable to include the directory where the python library is located.

MarkoPaul0 commented 3 years ago

Found where jep is installed, it was under /usr/local/bin/jep and this one runs properly. Next step will be to try and invoke some python code from java. Thanks a lot for unblocking me @ndjensen