Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
villares opened this issue Feb 13, 2024 · 20 comments
Open
Labels
help wanted Extra attention is needed

Comments

@villares
Copy link
Collaborator

villares commented Feb 13, 2024

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
Copy link
Collaborator

hx2A commented Feb 14, 2024

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

@villares
Copy link
Collaborator Author

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
Copy link
Collaborator

hx2A commented Feb 14, 2024

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
Copy link
Collaborator

hx2A commented Feb 14, 2024

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

@villares
Copy link
Collaborator Author

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
Copy link
Collaborator

hx2A commented Feb 14, 2024

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

@villares villares added the help wanted Extra attention is needed label Apr 28, 2024
@villares
Copy link
Collaborator Author

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
Copy link
Collaborator Author

villares commented Jun 19, 2024

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
Copy link

ericof commented Jul 12, 2024

@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:

  • /Users/ericof/Library/Thonny/jdk-17 does exist
  • /Users/ericof/Library/Thonny/jdk-17/Contents/Home/lib/libjli.dylib does exist
  • Outside Thonny I have the following setting: JAVA_HOME=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home that is used by my other py5 installation, and it works like charm

@hx2A
Copy link
Collaborator

hx2A commented Jul 12, 2024

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
Copy link

ericof commented Jul 14, 2024

@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
Copy link

ericof commented Jul 14, 2024

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

@hx2A
Copy link
Collaborator

hx2A commented Jul 21, 2024

@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?

py5coding/py5generator#464 (comment)

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
Copy link
Collaborator Author

villares commented Jul 21, 2024

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

  • py5coding,org ... install ... has some install variations, like, with pip or with conda, but also mentions the Thonny plug-in
  • I've been pointing students to a page I made, based on @tabreturn instructions, that now has EN, PT and ES versions...
    • It now (for the last several months I guess) recommends installing py5 via Thonny before the plug-in
    • Then you install the thonny-py5modeplug-in
    • Then at "first run" the plug-in will install the JDK and set Thonny's env vars with a JAVA_HOME

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
Copy link
Collaborator

hx2A commented Jul 21, 2024

@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
Copy link
Collaborator Author

@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
Copy link
Collaborator

hx2A commented Jul 21, 2024

@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
Copy link
Collaborator Author

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 😕

@ericof
Copy link

ericof commented Jul 22, 2024

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
Copy link
Collaborator Author

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: py5coding/py5generator#464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants