Closed villares closed 3 years ago
Hmmm. In the environment file http://py5.ixora.io/install/py5_environment.yml it instructs anaconda to install openjdk:
openjdk=11.0.8
But I don't see that listed in the list of things that are downloaded and extracted. Is it there and I missed it?
From the error message it looks like jpype is saying the jar file is compiled in a newer version of Java than what your JRE can handle. Installing that version of openjdk is supposed to take care of this.
Can you go to here:
http://py5.ixora.io/install/#detailed-steps
and look at the Install Java section? What version of Java do you have now? You will need Java 11.
Also, what kind of OS are you using? I thought you were a Windows user, but the file paths suggest Linux or OSX. Are you using the Window Linux subsystem?
I'm using Manjaro XFCE, I used to use Xubuntu and Mac OS but Macs became too expensive in Brazil. I sometimes have to use Windows for teaching too.
hmmm could it be that it was not istalled by conda? I might have installed it to test Processing 4 at some point.
Can I see the output of these commands, both inside and outside of the Anaconda environment:
$ which java
$ echo $JAVA_HOME
Also, from Python:
import jpype
jpype.getDefaultJVMPath()
For the last one I get '/Users/jim/INSTALL/anaconda3/envs/py5/lib/jli/libjli.dylib'
.
The JAVA_HOME environment variable needs to be set correctly for jpype to work.
Use the below command to install java in the Anaconda environment if it has not done so already:
$ conda install -c conda-forge openjdk=11.0.8
Also, the exception you are getting:
java.lang.java.lang.UnsupportedClassVersionError: java.lang.UnsupportedClassVersionError: py5/core/Py5Methods has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
The 52 and 55 refer to Java 8 and 11, respectively.
https://en.wikipedia.org/wiki/Java_class_file#General_layout
Somehow you are using Java 8 instead of Java 11. I suspect it is a problem with JAVA_HOME.
OH I THINK I FOUND SOMETHING!!!
So for some reason, when using Thonny it does not find the correct Java environment!
That's interesting. I wonder why Thonny does that. @tabreturn, you have experience with Thonny, can you provide some advice here?
Also, @tabreturn's blog post on py5 and thonny:
https://tabreturn.github.io/code/python/thonny/2021/06/21/thonny_and_py5.html
I suppose I'll have to go through the amazing self contained Thonny setup routine ¯_(ツ)_/¯
It would be great if py5, Java 11, and Thonny could be packaged together, kind of like how the Processing is packaged up with the PDE and a JRE.
BTW, Processing is moving to Java 16 or 17 or something in the Fall (I believe) so py5 will have to move also.
I have an idea to make some improvements to py5 so it provides more straightforward feedback when the version of Java is inadequate.
No, it think it's moving from 8 to 11
Yeah, a py5 bundle with Thonny would be awesome. Maybe we can build around their plug-ins feature...
VS Codium works fine for me now:-S
No, it think it's moving from 8 to 11
Right, but that move already happened in Processing 4. They are making a second move in the Fall to 17:
https://github.com/processing/processing4/wiki/Processing-4
Yeah, a py5 bundle with Thonny would be awesome. Maybe we can build around their plug-ins feature...
Yes, exactly. It may be a great fit.
VS Codium works fine for me now:-S
Excellent!
Jim, thanks again for everything. It's been hard ride lately. I feel like I just can't concentrate anymore.
Yesterday on a whim I decided to try and create a Python reading club. People like you motivate me to try to give back my best to the community.
I suppose I'll have to go through the amazing self contained Thonny setup routine ¯(ツ)/¯
Maybe you just need this part -- the line I added to the Thonny executable (thonny/bin/thonny):
export JAVA_HOME=/path/to/jdk'
Jim, thanks again for everything. It's been hard ride lately. I feel like I just can't concentrate anymore.
Yesterday on a whim I decided to try and create a Python reading club. People like you motivate me to try to give back my best to the community.
What a kind thing to say! Thank you so much for that. It means a lot. I didn't know what I was doing would motivate others to also contribute to the community. It happens I started py5 as an outlet for managing my pandemic related anxieties. If I am somehow also helping others with their pandemic anxieties, that's even better. :)
This thread gave me the idea of improving how py5 responds when the JVM won't start or the JVM version is insufficient. Below is an example from a test environment I created with Java 7. This is easier to follow than the nested Java exceptions you received. This exception will either guide the user to a proper fix or will assist anyone who is helping them:
In [1]: import py5
py5 is unable to start a Java 11 Virtual Machine.
This library requires Java 11 to be installed and a properly set JAVA_HOME environment variable.
Here is some debug info about your installation that might help you identify the source of this problem.
{'JAVA_HOME environment variable': '/home/jim/INSTALL/anaconda3/envs/java7test', 'jvm version': (0, 0, 0), 'default jvm path': '/home/jim/INSTALL/anaconda3/envs/java7test/x86_64-conda-linux-gnu/sysroot/usr/lib64/jvm/java-1.7.0-openjdk-1.7.0.181.x86_64/jre/lib/amd64/server/libjvm.so'}
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-1-6c88b15a5077> in <module>
----> 1 import py5
~/Projects/ITP/pythonprocessing/py5code/py5/__init__.py in <module>
55 print("Here is some debug info about your installation that might help you identify the source of this problem.", file=sys.stderr)
56 print(debug_info, file=sys.stderr)
---> 57 raise RuntimeError("py5 is unable to start Java 11 Virtual Machine")
58
59 from .methods import register_exception_msg # noqa
RuntimeError: py5 is unable to start Java 11 Virtual Machine
SUCCESS!
Under Tonny options, set environment variable to JAVA_HOME=/home/villares/miniconda3/envs/py5coding/
(and don't forget the trailing slash!)
Thanks for sharing, @villares! I totally overlooked this feature in Thonny.
I just updated the install docs with the lessons learned from this thread:
I'm probably doing something wrong, please forgive me. I decided to try this instruction:
conda env create -n py5coding -f http://py5.ixora.io/install/py5_environment.yml
Then I tried running this example:
So I've got this error (also, should conda have created a Python 3.9 env?):
My conda reported this on env creation: