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

jdk-install might be failing to make available a JDK on Apple Silicon Macs #55

Open villares opened 6 months ago

villares commented 6 months ago

I have a number of students with M1, M2 & M3 Macs telling me they had to manually install JDK-17 from download.oracle.com/java/17/archive/jdk-17.0.10_macos-aarch64_bin.dmg and then added the correct path to Thonny's environment variables options panel...

This has been a source of pain, I'd like to reproduce and fix this issue but I have no access to Apple Silicon CPU Macs...

cc @ericof

hx2A commented 6 months ago

Does the maintainer of install-jdk know about this issue? I recall he seemed pretty diligent about investigating problems.

villares commented 6 months ago

Does the maintainer of install-jdk know about this issue? I recall he seemed pretty diligent about investigating problems.

I saw a related issue at their repo, closed, not too long ago. The problem is I'm unable/unwilling to open a new issue there without being able to reproduce, or at least describe precisely, the problem :(

hx2A commented 6 months ago

The problem is I'm unable/unwilling to open a new issue there without being able to reproduce, or at least describe precisely, the problem

That is the right thing to do.

hx2A commented 6 months ago

This doesn't happen on all M1,M2, and M3 machines, right? Just some of the time?

villares commented 6 months ago

This doesn't happen on all M1,M2, and M3 machines, right? Just some of the time?

I really don't know :( The only Macs I have access to are Intel.

hx2A commented 6 months ago

I think @tabreturn has one? He had one when he opened this issue.

villares commented 4 months ago

Please @tabreturn and @ericof and anyone with Apple Silicon, can we please check this? I'm trying to reach a student with a M1 today, let's see how it goes...

villares commented 2 months ago

Hi @ericof and @tabreturn, it would be great if we could check this JDK install thing and coordinate a fix or a warning in a new thonny-py5mode release soon.

The numpy 2.0 update, and the ability to avoid it by using the newest py5 version, makes a new release kind of a pressing issue.

ericof commented 1 month ago

@villares, @tabreturn, I tried to install everything from scratch on my M1 computer, but it did not have a positive outcome.

The error message is the following:

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/ericof/Library/Thonny/jdk-17', 'jvm version': (0, 0, 0), 'default jvm path': '/Users/ericof/Library/Thonny/jdk-17/Contents/Home/lib/libjli.dylib'}
Traceback (most recent call last):
  File "/Users/ericof/Library/Thonny/plugins/lib/python/site-packages/py5_tools/tools/run_sketch.py", line 52, in <module>
    main()
  File "/Users/ericof/Library/Thonny/plugins/lib/python/site-packages/py5_tools/tools/run_sketch.py", line 44, in main
    imported.run_code(
  File "/Users/ericof/Library/Thonny/plugins/lib/python/site-packages/py5_tools/imported.py", line 135, in run_code
    _run_code(
  File "/Users/ericof/Library/Thonny/plugins/lib/python/site-packages/py5_tools/imported.py", line 259, in _run_code
    _run_sketch(sketch_path, classpath, exit_if_error)
  File "/Users/ericof/Library/Thonny/plugins/lib/python/site-packages/py5_tools/imported.py", line 196, in _run_sketch
    import py5
  File "/Users/ericof/Library/Thonny/plugins/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

Also, running the following code on the Thonny shell:

>>> import jpype
>>> jpype.startJVM()

The following error was raised:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ericof/Library/Thonny/plugins/lib/python/site-packages/jpype/_core.py", line 224, in startJVM
    _jpype.startup(jvmpath, tuple(args),
FileNotFoundError: [Errno 2] JVM DLL not found: /Users/ericof/Library/Thonny/jdk-17/Contents/Home/lib/libjli.dylib

Important points:

hx2A commented 1 month ago

Hi @ericof !

If you set JAVA_HOME to point to the same JDK that Thonny is attempting to use, does it work? Is jdk-install somehow installing a JDK that does not work on Apple Silicon machines?

It happens I now have a M1 Mac and I will have some time next week to investigate this.

ericof commented 1 month ago

@hx2A I just tested it, and it will not work either. One important point, Thonny sets:

JAVA_HOME=/Users/ericof/Library/Thonny/jdk-17/

My working installation points to

JAVA_HOME=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home

Attention to the /Contents/Home (I also tried to set JAVA_HOME pointing to /Users/ericof/Library/Thonny/jdk-17/Contents/Home, but it did not work as well)

ericof commented 1 month ago

Additional information: if I set, on Thonny, JAVA_HOME to the other installation, it works

hx2A commented 1 month ago

@hx2A I just tested it, and it will not work either. One important point, Thonny sets:

JAVA_HOME=/Users/ericof/Library/Thonny/jdk-17/

My working installation points to

JAVA_HOME=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home

Attention to the /Contents/Home (I also tried to set JAVA_HOME pointing to /Users/ericof/Library/Thonny/jdk-17/Contents/Home, but it did not work as well)

Interesting. Is @vsquared's post here helpful to you?

https://github.com/py5coding/py5generator/discussions/464#discussioncomment-9565567

Recently I purchased a Apple Silicon M1 laptop. I installed Thonny and this plugin using the install steps. I didn't previously install Java or py5 anywhere else on the machine. Thonny was able to run py5 without any problems. The install steps worked perfectly. Which is unfortunate, because I was hoping to reproduce a M1 related problem.

As I learn more about this machine and setup, I hope to experience some MacOS problems so I can find solutions to them.

villares commented 1 month ago

@hx2A and @ericof , can you both please clarify which version of the installing instructions you used?

If you haven't yet, could you please test these later versions? Or in case you did that, could you try not installing py5 beforehand to see what happens?

hx2A commented 1 month ago

@hx2A and @ericof , can you both please clarify which version of the installing instructions you used?

I followed the instructions on the plugin github page:

https://github.com/tabreturn/thonny-py5mode

I did not install java or py5 before I installed the plugin. The plugin setup process did both of those for me.

villares commented 1 month ago

@hx2A, if you have the time, please check what happens if you install py5 (from the Thonny manage packages dialog) before the plug-in. Beware Thonny might be leaving behind a "sites-packages" somewhere in your user folder.

hx2A commented 1 month ago

@hx2A, if you have the time, please check what happens if you install py5 (from the Thonny manage packages dialog) before the plug-in. Beware Thonny might be leaving behind a "sites-packages" somewhere in your user folder.

Sure, I can do that. How do I get to a clean slate? Should I uninstall Thonny first? Is there another folder I must get rid of?

villares commented 1 month ago

Good question... There is no central "uninstall" on MacOS, I think, and on Windows I know it leaves behind things at <username>\AppData\Roaming\Python\Python310\site-packages... so maybe you could try searching, I'm not sure :confused:

ericof commented 1 month ago

I will remove Thonny (I have this old app called TrashMe that claims to scrub any installation) and try to install it again following the documentation. Of course, I will keep my other working Java environment (as it is used by some Brazilian Government apps that I need to use on a regular basis)

villares commented 2 weeks ago

How are we going with this issue?

I want to close this related discussion at the py5generator repo, so I'll mention it here ant close it there: https://github.com/py5coding/py5generator/discussions/464