py5coding / py5generator

Meta-programming project that creates the py5 library code.
GNU General Public License v3.0
48 stars 13 forks source link

Trouble running code with imported mode for py5 in Thonny #436

Closed JotaCamargo closed 1 month ago

JotaCamargo commented 3 months ago

Hi. I am looking to learn the fundamentals of creative coding in py5, and have previously installed Thonny and installed the thonny-py5mode plugin as well, acording to the instructions in a tutorial. Once I do everything that is supposed to be done and start writing code and playing it, it doesn't run, and in the console I get a text saying: "RuntimeError: py5 is unable to start Java 17 Virtual Machine". I am looking for how to solve this problem but I don't know how to do it. I don´t know why this has happened, if someone can help me to understand what can I do to solve it, I will be very grateful.

hx2A commented 3 months ago

Hi, @JotaCamargo !

Hmmm, this is a problem we've seen before. The thonny plugin is supposed to take of this, but sometimes you need to intervene to get it to work.

Can you tell us more about your computer? What kind of computer is it? If this is an apple computer, is it one of the Apple Silicon machines?

@villares is the expert at solving these kinds of problems and I know he'll have good advice for what to do.

john-humphries commented 3 months ago

Hi, I have the same issue. I also get a message indicating that an environment variable JAVA_HOME hasn't been set. I have tried the recommended suggestions. I have been running Thonny on iMac and Windows platforms for several years and never had this issue with plug-ins. I look forward to your advice.

hx2A commented 3 months ago

Hi, @john-humphries ! @villares and I have seen this problem before and will be happy to help you with this.

py5 is different from other Python libraries in that you are required to install a Java Virtual Machine. Your computer probably doesn't have that by default. Have you installed that already? How did you install it?

Can you copy paste the exact error message you are getting or perhaps provide a screenshot?

Thanks!

john-humphries commented 3 months ago

Appreciate your rapid response!

Was trying to run this example on Windows 10 (it now works correctly on my iMac - I don't know why):

import py5 as py5

def setup(): py5.size(200, 200) py5.rect_mode(py5.CENTER)

def draw(): py5.rect(py5.mouse_x, py5.mouse_y, 10, 10)

py5.run_sketch()

And get this:

Traceback (most recent call last): File "C:\Users\john\AppData\Local\Programs\Thonny\lib\site-packages\py5_tools\tools\run_sketch.py", line 58, in main() File "C:\Users\john\AppData\Local\Programs\Thonny\lib\site-packages\py5_tools\tools\run_sketch.py", line 49, in main imported.run_code( File "C:\Users\john\AppData\Local\Programs\Thonny\lib\site-packages\py5_tools\imported.py", line 148, in run_code _run_code( File "C:\Users\john\AppData\Local\Programs\Thonny\lib\site-packages\py5_tools\imported.py", line 304, in _run_code _run_sketch(sketch_path, classpath, exit_if_error) File "C:\Users\john\AppData\Local\Programs\Thonny\lib\site-packages\py5_tools\imported.py", line 226, in _run_sketch import py5 File "C:\Users\john\AppData\Local\Programs\Thonny\lib\site-packages\py5__init__.py", line 62, in debug_info = py5_tools.get_jvm_debug_info() File "C:\Users\john\AppData\Local\Programs\Thonny\lib\site-packages\py5_tools\jvm.py", l...

villares commented 3 months ago

Cheers John!

Confirm for me please that your Thonny has a py5 menu. With the py5 menu > imported mode for py5 option turned on/checked, your test code should be like this (no need for the py5 import and prefix):

def setup():
    size(200, 200)
    rect_mode(CENTER)

def draw():
    rect(mouse_x, mouse_y, 10, 10)

Otherwise, using the imported mode off/unchecked you should be able to run this:

import py5

def setup():
    py5.size(200, 200)
    py5.rect_mode(py5.CENTER)

def draw():
    py5.rect(py5.mouse_x, py5.mouse_y, 10, 10)

py5.run_sketch()

Does these change the error messages?

Also you could try on the shell (the bottom part of Thonny's window with >>>) import py5 (and press ENTER)

Then we can investigate together further!

john-humphries commented 3 months ago

Hi, Tried your suggestions but still no luck. I'm away for a few weeks now and will take it up again on my reurn. Thanks again, John

villares commented 3 months ago

Hi, Tried your suggestions but still no luck. I'm away for a few weeks now and will take it up again on my reurn. Thanks again, John

When you are back, tell me about the import py5 result, copy here the complete error from the shell, and we will try some other debugging explorations, thanks!

PS: Are you using the Thonny portable from my dropbox ?

villares commented 1 month ago

Cheers @john-humphries! Have you had the chance to try again and the "portable" Thonny from my dropbox link?

villares commented 1 month ago

Hi @JotaCamargo! Have you made it work for you?

We might want to close this issue for now, OK?

john-humphries commented 1 month ago

Hi Alexandre,

Yes, this enquiry can be closed. Thank you Kind regards

John

On Sat, 25 May 2024 at 19:35, Alexandre B A Villares < @.***> wrote:

Closed #436 https://github.com/py5coding/py5generator/issues/436 as completed.

— Reply to this email directly, view it on GitHub https://github.com/py5coding/py5generator/issues/436#event-12933682398, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARWEQI4JDWG5AGTEGWGV3FTZEDKXHAVCNFSM6AAAAABFEDHZGCVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSHEZTGNRYGIZTSOA . You are receiving this because you were mentioned.Message ID: @.***>