py5coding / py5generator

Meta-programming project that creates the py5 library code.
GNU General Public License v3.0
48 stars 13 forks source link

Java 17 virtual machine issue: py5 Thonny Macbook M1 Max #452

Closed david-dunkley closed 2 months ago

david-dunkley commented 2 months ago

Hi, I'm trying to run py5 in thonny and have received the following error. Any suggestions would be helpful. My MacBook chip is Apple M1 max. OS is ventura 13.5.2. Thanks

py5_ Thonny_Mac2024-05-01 at 1 47 34 PM
villares commented 2 months ago

Hi @david-dunkley !

I'm sorry that you are having trouble with this, but I'm glad you opened this issue so we might investigate this, solve it for you and eventually solve it for everyone using Thonny and the py5 plug-in for Thonny... From your screen capture I gather you are using Thonny IDE and the thonny-py5mode plug-in, right?

Can you please open on Thonny's menu Tools > Options... then on General Tab check if there is JAVA_HOME=... on the Environment Variables box? Does the path there seem sensible? Can you check if it points to an existing folder?

My next steps would be to ask you to try using the most recent install-jdk library (which the plug-in uses) install a (new? correct?) JDK... I would give you more instructions. But then, you could also try to manually install a working JDK... what do you think?

villares commented 2 months ago

You will, hopefully, be helping us fix this related issue: https://github.com/tabreturn/thonny-py5mode/issues/55

hx2A commented 2 months ago

Thank you, @villares !

I'll also note that the error message mentions "amazon corretto 11" as the default Java version. py5 requires Java 17 or higher. Also, I am not familiar with amazon corretto JVMs and would suggest you stick with oracle or openjdk instead.

david-dunkley commented 2 months ago

Thanks @villares and @hx2A ! I will try to fix this using your suggestions! py5 does work on my machine when I use a virtual environment in PyCharm, but I wanted to also get Thonny going as well.

villares commented 2 months ago

Cheers David!

So, just to make it work, I would try to find your "working" JDK and add the path to it to Thonny's JAVA_HOME env var settings in options.

UPDATE: You could also try pointing Thonny to your PyCharm env Python under Otions > Interpreter, maybe?

If you want to explore more I would try to uninstall the thonny-py5mode plugin, then install with Thonny packages manager the latest install-jdk library and py5 and then re-install the plug-in to see if it works...

hx2A commented 2 months ago

Also, since this is using Apple Silicon, be aware of this issue:

https://blogs.oracle.com/java/post/java-on-macos-14-4

david-dunkley commented 2 months ago

Hi @villares & @hx2A ,

I fixed the problem by removing the old jdks from the library. The amazon-corretto-17.jdk proved stubborn as I had to change its name to simply jdk-17. Then I did a: sudo rm - rf /Library/Java/JavaVirtualMachines/jdk-17.jdk to remove. Now Thonny finds the pathway I set up within it. Thanks again and py5 is really great.

david-dunkley commented 2 months ago

...I also installed home-brew and installed java jdk 21 through openjdk. Hope this helps if any Mac M1 users need it!

hx2A commented 2 months ago

Awesome @david-dunkley , very happy you have it working! If you have any more problems or ideas, you know where to find us!

Also, since you have the problem fixed, can we close this?

david-dunkley commented 2 months ago

Yes, @hx2A we can close the issue. Thanks!

LeMasters commented 1 month ago

With the latest install of Thonny on a Mac m3, I'm getting the same error.

py5 is unable to start a Java 17 Virtual Machine. This library requires Java 17 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': '/Users/garrisonlemasters/Library/Thonny/jdk-17', 'jvm version': (0, 0, 0), 'default jvm path': '/Users/garrisonlemasters/Library/Thonny/jdk-17/Contents/Home/lib/libjli.dylib'}

In the Thonny TOOLS>OPTIONS panel, it lists the JAVA_HOME variable as above.

The default JVM path DOES contain the libjli.dylib file (among other things).

In my terminal,java -version tells me there's no java installed. echo $JAVA_HOME gives me a blank line.

I was faithful about following THONNY's install instructions. Is it best to uninstall everything and start by installing a free-standing version of the JDK independently of THONNY?

villares commented 1 month ago

Is it best to uninstall everything and start by installing a free-standing version of the JDK independently of THONNY?

Hi @LeMasters, I'm afraid it might be the best option, according to some reports I have been hearing from people.

You could then still use Thonny setting the JAVA_HOME variable in the preferences according to your independent install.

I would love to know if it would work using the jdk_install library as described in http://py5coding.org/content/install.html?highlight=jdk+install#install-java

If it doesn't work, maybe you could try "homebrew" with https://formulae.brew.sh/formula/openjdk@17

Please keep us posted on your progress! I hope this works!

david-dunkley commented 1 month ago

Hi Everyone,I had the same issue and it was resolved by installing a fresh JDK (I think I used homebrew).  I then removed all the old JDK's. Next, I copied the path to the fresh JDK and pasted it into the Thonny settings so that Thonny could find the JDK. It worked and has worked since then.Best,DavidOn Jun 11, 2024, at 14:04, Alexandre B A Villares @.***> wrote:

Is it best to uninstall everything and start by installing a free-standing version of the JDK independently of THONNY?

Hi @LeMasters, I'm afraid it might be the best option, according to some reports I have been hearing from people. You could then still use Thonny setting the JAVA_HOME variable in the preferences according to your independent install. I would love to know if it would work using the jdk_install library as described in http://py5coding.org/content/install.html?highlight=jdk+install#install-java If it doesn't work, maybe you could try "homebrew" with @.*** Please keep us posted on your progress! I hope this works!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>