tabreturn / thonny-py5mode

A py5 plug-in for Thonny
Do What The F*ck You Want To Public License
23 stars 8 forks source link

No luck running on M1 Mac #20

Closed caluap closed 1 year ago

caluap commented 2 years ago

Hi! I tried installing and running py5, but it isn't able to find the JDK.

There were no error messages during the installation and configuration of the plugin, but when I tried to run a script I got:

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/calua/Library/Thonny/jdk-17', 'jvm version': (0, 0, 0), 'default jvm path': '/Users/calua/Library/Thonny/jdk-17/Contents/Home/lib/libjli.dylib'}
Traceback (most recent call last):
  File "/Users/calua/Library/Python/3.9/lib/python/site-packages/py5_tools/tools/run_sketch.py", line 52, in <module>
    main()
  File "/Users/calua/Library/Python/3.9/lib/python/site-packages/py5_tools/tools/run_sketch.py", line 44, in main
    imported.run_code(
  File "/Users/calua/Library/Python/3.9/lib/python/site-packages/py5_tools/imported.py", line 135, in run_code
    _run_code(
  File "/Users/calua/Library/Python/3.9/lib/python/site-packages/py5_tools/imported.py", line 259, in _run_code
    _run_sketch(sketch_path, classpath, exit_if_error)
  File "/Users/calua/Library/Python/3.9/lib/python/site-packages/py5_tools/imported.py", line 196, in _run_sketch
    import py5
  File "/Users/calua/Library/Python/3.9/lib/python/site-packages/py5/__init__.py", line 72, in <module>
    raise RuntimeError("py5 is unable to start Java 17 Virtual Machine")
RuntimeError: py5 is unable to start Java 17 Virtual Machine

The options show that JAVA_HOME is set:

Screen Shot 2022-06-14 at 18 54 36

tabreturn commented 2 years ago

Thanks for the report. Which version of Thonny are you running?

caluap commented 2 years ago

3.3.7 Screen Shot 2022-06-15 at 09 58 59

tabreturn commented 2 years ago

Thanks! It might be that JRE isn't installing properly, or maybe not to the JAVA_HOME path. I'll investigate ...

caluap commented 2 years ago

Thank you!

villares commented 2 years ago

Thanks for the report @caluap! I think you showed me the contents of the folder pointed by JAVA_HOME and there was something installed there, do I remember it correctly?

I find this MacOS "Contents" hidden folder inside applications a bit confusing (not sure this is the case, here). Is the second path shown in the debug info a valid one? {'JAVA_HOME environment variable': '/Users/calua/Library/Thonny/jdk-17', 'jvm version': (0, 0, 0), 'default jvm path': '/Users/calua/Library/Thonny/jdk-17/Contents/Home/lib/libjli.dylib'}

villares commented 2 years ago

Cheers @caluap!

I wonder if you could try setting JAVA_HOME "outside" Thonny, like I did for my Windows batch-file for Portable Thonny... This is from a confusing Oracle documentation:

$ export JAVA_HOME=`/usr/libexec/java_home -v 17`
tabreturn commented 1 year ago

I encountered issues with Thonny 4.0.1. It seems JDK-17 is unhappy on my M1 machine. So I manually downloaded and extracted JDK-18, then set the path (in Thonny options) manually, and things ran fine. So maybe just requires jdk-install to use JDK-18. I will test and amend it for the next release (if 18 solves the problem).

villares commented 1 year ago

Cheers @caluap !

My friend @ericof managed py5 in his M1 Mac, can you give it another go? Maybe you could ask Erico for help...

tabreturn commented 1 year ago

Just got a MacBook Pro M2. This commit, which will be in the next release, should solve the problem --

https://github.com/tabreturn/thonny-py5mode/commit/72080927b7523a3e47a7ad3ea31f0c4c9d2e760c

No idea if this breaks M1 support ...