py5coding/py5generator

javaaccessbridge trouble on Windows 10

Closed this issue ยท 14 comments

I have a student using Thonny on Windows 10, even without using the thonny-py5mode plugin their sketches throw an error. import py5 does not complain, but running a simple sketch fails:

import py5

def setup():
    py5.size(400, 400)
    py5.rect(100, 100, 100, 100)

py5.run_sketch()

Error:

Java exception thrown by Sketch.runSketch:
java.lang.UnsatisfiedLinkError: C:\Users\Josi\Downloads\CursoMAM\thonny-4-with-py5-windows-portable\user_data\jdk-17\bin\javaaccessbridge.dll: Can't find dependent libraries

I have tried re-installing the JDK but it didn't work.

hx2A commented

How was the JDK installed? By the plugin, with install-jdk? Is thonny-4-with-py5-windows-portable the portable install you created?

I wonder what dependent library it can't find. I wish the error message would provide that information.

Can you try commenting out py5.run_sketch() and see if there is an error? I'd like to know if the error occurs when py5 is imported or when it tries to run a Sketch.

hx2A commented

If it fails on import py5, please try:

import jpype

jpype.startJVM()

If it fails on run_sketch(), please try changing the renderer to P2D.

She had the portable, but we deleted the JDK, uninstalled the plug-in, and re-istalled it so it re-installed the JDK using the install-jdk based feature. I'm quite sure it won't fail without the py5.run_sketch() because I tried import py5 in the REPL. I'll ask her to try the P2D test.

hx2A commented

When you say you tested it in the REPL, what do you mean? Is that the same Python environment Thonny is using or a different one?

Thonny has an interactive prompt in the lower part of the window, using the same Python as the one called by he run button for the files edited at the upper IDE part. So I often test if py5 was correctly installed by typing import py5 and then py5.__version__ there.

A quick illustration from my Sesc-job computer right now:
image

But back to my student... she confirmed that:

  • without py5.run_sketch(), in module mode, no error is emmited (but obviously no sketch runs);
  • P2D did not change anything either in imported mode or module mode (same error message);
  • jpype.startJVM() executes silently also (I thought it wouldn't cost to check).
hx2A commented

Is this one of your remote students? Any chance she can follow the py5 install steps and install anaconda, create an environment, etc?

http://py5coding.org/content/install.html

I'd like to know if an alternate installation method works to get around the problem.

hx2A commented

Also, maybe try installing the Processing PDE and running a Sketch from there.

OK. Yes, she is a remote student. I'll have to check if she has the time, and HD space, for the conda env method.

Question: could we recommend miniconda instead of full anaconda in the docs?

Also @hx2A, as Thonny 4 is Python 3.10.8 would it be a problem to suggest something similar on the conda env? The current base miniconda env is 3.10.9.

hx2A commented

I don't have much experience with miniconda, but I imagine it would still work. Maybe we can update the docs to suggest it as an alternative.

UPDATE: I tried with her the anaconda approach and couldn't make it work :( but not the same error, the JDK-17, installed with the install-jdk was not seen. But I'd rather not burden her with more experiments.
She has a laptop from her employer, also Windows 10, that works with the same initial Thonny portable folder, copied with a thumbdrive... it's a working workaround for now.

We could leave this open for a while to see if someone else has the same problem, and eventually close this.

hx2A commented

Also @hx2A, as Thonny 4 is Python 3.10.8 would it be a problem to suggest something similar on the conda env? The current base miniconda env is 3.10.9.

Good point! When I started py5, 3.8 was a newer version than most people are using. Now it is kind of old. It is the minimum required version but it shouldn't be the recommended version. I do do dev work in 3.8 to ensure I don't add any non 3.8 features, but that is not relevant to users.

LAST UPDATE: She insisted and made it work somehow! Hurray! She tried many things, like installing JDK 18 and setting JAVA_HOME, setting a JRE home also... on Windows those were not set. (Remember the instructions say you don't have to set JAVA_HOME...).

So I'll close this for now. Thanks for the always kind support!

hx2A commented

LAST UPDATE: She insisted and made it work somehow! Hurray! She tried many things, like installing JDK 18 and setting JAVA_HOME, setting a JRE home also... on Windows those were not set. (Remember the instructions say you don't have to set JAVA_HOME...).

So I'll close this for now. Thanks for the always kind support!

Great! Very happy to hear your student persevered and got it to work. Please tell her that kind of determination will get her far in the programming world.

I opened an issue in py5book to track the install instruction updates suggested in this thread:

py5coding/py5book#92