-
I am unable to run test code on an Apple M2 Mac with the error message shown above . I have the py5 plugin installed on Thonny with the requisite JDK-17. The HOME_PATH accurately reflects the location of JDK-17. The installation has failed with the same error message on another M2 mac belonging to someone else, so I know that it is not unique to my system. I have also installed 'Conda' thinking it would help, but do not know how to use it; it appears to be a cmd-line app run with Terminal. Any advice would be appreciated. Here's the entire error message:
It appears to ultimately trace back to a function in the file 'py5_tools.jvm._start_jvm', def _start_jvm(). If that helps any. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
It is true that others have had problems with py5 on the M2 machines but we've always been able to work through it to get it working. Can you tell me what version of py5 you have installed? If it is not the most current, can you upgrade? How did you install Java on this machine? |
Beta Was this translation helpful? Give feedback.
-
Hi @vsquared, I'm going to close this for now. I think the solution might be to (re)install a JDK built for Apple Silicon as reported at #452 If you want to re-open this discussion, please create a new one naming the OS/Architecture on the subject, as it makes for more targeted discussion and attracts people with the same hardware. |
Beta Was this translation helpful? Give feedback.
-
I apologize for this long response but this is more complicated than I thought; bear with me. One copy of jdk-17.jdk resides on the Macintosh HD at /Library/Java/JavaVirtualMachines. If you have a brand new system there likely will be nothing in the JavaVirtualMachines folder. If you used TimeMachine to 'clone' your old Intel mac there may be a jdk-17 folder in there, but it is for your old mac (x86_64) which will not work with the Thonny editor on a new M2 mac and you will get a 'py5 is unable to start Java 17 Virtual Machine' error. What you need for a new M2 mac system is a jdk-17 for aarch64. To avoid confusion, it is probably best to delete the old jdk. You can do that with the Terminal cmd-line using this code: sudo rm -rf pathToFile. If you look into the JVM folder you should see that the old jdk-17 folder is now gone. Next do a browser search for download jdk 17 for mac and you should see an Oracle website where you can download jdk-17. Look for a version for the newer macs with an M2 chip; it should be labelled jdk-17_macos-aarch64_bin.dmg. When you have downloaded the .dmg file to your system click on it to setup the installer. The jdk will be automatically installed into Macintosh HD/Library/Java/JavaVirtualMachines; you can open the folder to check and see that the new jdk is now in place of the old one. The next thing you have to do is edit the .zshrc file in Terminal to make certain that the JAVA_HOME path is set correctly. On the cmd-line type vi .zshrc to open the file or create a new one if it doesn't already exist. You should see the following at the top of the file: JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home; if it's not there go ahead and edit the file by typing 'i' which will allow you to insert it. When you get all done typing hit the escape key ('esc') followed by ':wq' at the bottom of the file to save your changes. You may navigate up and down in the .zshrc file with the arrow keys. If you have 'conda' installed you may see their code in the file also; just leave it as is. The only thing now left to do is set JAVA_HOME in the Thonny editor to match what you just entered into the .zshrc file. Under the Tools menuItem on the toolbar select Options... Under the 'General' tab you should see a large white rectangle at the bottom for you to enter or copy/paste the same HOME_PATH that you entered in .zshrc. 'OK' the change and quit Thonny. When you re-open Thonny you should no longer see the error message about being unable to start a java virtual machine. I found the following YouTube video to be very helpful: https://www.youtube.com/watch?v=n15tOYj6d4E Addendum: Addendum 2: Addendum 3: |
Beta Was this translation helpful? Give feedback.
-
Moving this to tabreturn/thonny-py5mode#55 as it seems to be a py5-mode plug-in issue! |
Beta Was this translation helpful? Give feedback.
I apologize for this long response but this is more complicated than I thought; bear with me.
One copy of jdk-17.jdk resides on the Macintosh HD at /Library/Java/JavaVirtualMachines. If you have a brand new system there likely will be nothing in the JavaVirtualMachines folder. If you used TimeMachine to 'clone' your old Intel mac there may be a jdk-17 folder in there, but it is for your old mac (x86_64) which will not work with the Thonny editor on a new M2 mac and you will get a 'py5 is unable to start Java 17 Virtual Machine' error. What you need for a new M2 mac system is a jdk-17 for aarch64. To avoid confusion, it is probably best to delete the old jdk. You can do that with the Termi…