ninia / jep

Embed Python in Java
Other
1.28k stars 145 forks source link

Trouble installing jep via pip [python 3.11.4] #482

Open Nathan22211 opened 1 year ago

Nathan22211 commented 1 year ago

Describe the problem jep fails to install via pip in python 3.11

Search for existing solutions The Jep build is automatically tested and confirmed to be working in Linux, OS X, and Windows using Travis and AppVeyor. We cannot possibly test every environment so we rely on the community to document any issues and solutions in other environments. Please search for a similar problem and solution on both the mailing list and the existing closed github issues before opening a new issue.

Environment (please complete the following information):

Logs ` Using cached jep-4.1.1.tar.gz (3.0 MB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [2 lines of output] Error: Please set the environment variable JAVA_HOME to a path containing the JDK. [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.`

Additional context I have 2 java versions installed, one for Minecraft, as there's a mod that uses jep, and one for general development

bsteffensmeier commented 1 year ago

Please set the environment variable JAVA_HOME to a path containing the JDK.

Nathan22211 commented 1 year ago

Is that doable per pipvenv? I might need to use a different version of java in one project from the version used for the minecraft mod

bsteffensmeier commented 1 year ago

When you install jep it needs to build the native library using the JNI headers included with your JVM so it needs to know where java is installed. I don't have much experience with pipvenv but if you install jep separately into a different venv then it could use different java installation during installation. I also believe the JNI headers are usually compatible so you may be able to use the same native library with different java installations but it isn't something I have done before so I cannot say with 100% certainty what will work in your environment.

Nathan22211 commented 1 year ago

When you say the environment variable, is that a python variable of some sort or a system variable? I've never used env variables in Python before 😅

bsteffensmeier commented 1 year ago

It is a system variable, I don't develop jep on windows so I don't have instructions on how to set it but it is a common setting for java apps so you should be able to find help online, for example these instructions look accurate to me.

goldenretriever98 commented 11 months ago

I have set the JAVA_HOME and I am getting a new error

/opt/conda/compiler_compat/ld: cannot find -ljvm: No such file or directory
      collect2: error: ld returned 1 exit status
      error: command '/usr/bin/gcc' failed with exit code 1

Could anyone tell me what is going wrong ?

ndjensen commented 11 months ago

@goldenretriever98, the error message means it can't find libjvm. Are you on macOS or Linux? Check the directory $JAVA_HOME/lib for libjvm.dylib on macOS or libjvm.so on Linux. If it's not there maybe you have locate enabled and could do locate libjvm to try and find it and change the JAVA_HOME environment variable accordingly.