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

Failed loading plugin thonnycontrib.backend.py5_imported_mode_backend. See backend.log for more info. #63

Open ilhamfs7 opened 3 months ago

ilhamfs7 commented 3 months ago

Hi, I'm a beginner here; I found it a task as a student to use thonny-py5mode. But I found the problem immediately after I downloaded thonny-py5mode in manage packages/manage plugins. The problem is as follows: Screenshot (2) it says failed loading plugin thonnycontrib, and when i take a look to Backend.log, it says like this :

19:50:14.816 ERROR thonny.backend: Failed loading plugin thonnycontrib.backend.py5_imported_mode_backend Traceback (most recent call last): File "C:\Users\muhil\Thonny\thonny-4-with-py5-windows-portable\lib\site-packages\thonny\plugins\cpython_backend\cp_back.py", line 314, in _load_plugins_from_path m = importlib.import_module(module_name) File "C:\Users\muhil\Thonny\thonny-4-with-py5-windows-portable\lib\importlib__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "C:\Users\muhil\Thonny\thonny-4-with-py5-windows-portable\user_data\plugins\Python310\site-packages\thonnycontrib\backend\py5_imported_mode_backend.py", line 9, in from py5_tools import imported File "C:\Users\muhil\Thonny\thonny-4-with-py5-windows-portable\lib\site-packages\py5_tools__init__.py", line 23, in from .imported import set_imported_mode, get_imported_mode, _lock_imported_mode # noqa File "C:\Users\muhil\Thonny\thonny-4-with-py5-windows-portable\lib\site-packages\py5_tools\imported.py", line 29, in from . import JVM File "C:\Users\muhil\Thonny\thonny-4-with-py5-windows-portable\lib\site-packages\py5_tools\jvm.py", line 31, in import jpype File "C:\Users\muhil\Thonny\thonny-4-with-py5-windows-portable\lib\site-packages\jpype__init.py", line 18, in import _jpype ImportError: DLL load failed while importing _jpype: The specified module could not be found. 19:50:14.816 INFO thonny: TIME/MODS 0.485 Sending message ProgramOutput (+162 modules) 19:50:14.816 INFO thonny: NEW MODS ['future', 'mp_main', '_bisect', '_blake2', '_compat_pickle', '_ctypes', '_cython_0_29_32', '_datetime', '_hashlib', '_json', '_pickle', '_random', '_sha512', '_socket', '_struct', 'base64', 'binascii', 'bisect', 'colorsys', 'ctypes', 'ctypes._endian', 'cython_runtime', 'datetime', 'glob', 'hashlib', 'hmac', 'json', 'json.decoder', 'json.encoder', 'json.scanner','math','multiprocessing','multiprocessing.context','multiprocessing.process','multiprocessing.reduction','math', 'multiprocessing', 'multiprocessing.context', 'multiprocessing.process', 'multiprocessing.reduction', 'numbers', 'numpy', 'numpy.config', 'numpy._distributor_init', 'numpy._globals', 'numpy._pytesttester', 'numpy._version', 'numpy.compat', 'numpy.compat._inspect', 'numpy.compat._pep440', 'numpy.compat.py3k', 'numpy.core', 'numpy.core._add_newdocs', 'numpy.core._add_newdocs_scalars', 'numpy.core._asarray', 'numpy.core._dtype', 'numpy.core._dtype_ctypes', 'numpy.core._exceptions', 'numpy.core._internal', 'numpy.core._machar', 'numpy.core._methods', 'numpy.core._multiarray_tests', 'numpy.core._multiarray_umath', 'numpy.core._string_helpers', 'numpy.core._type_aliases', 'numpy.core._ufunc_config', 'numpy.core.arrayprint', 'numpy.core.defchararray', 'numpy.core.einsumfunc', 'numpy.core.fromnumeric', 'numpy.core.function_base', 'numpy.core.getlimits', 'numpy.core.memmap', 'numpy.core.multiarray', 'numpy.core.numeric', 'numpy.core.numerictypes', 'numpy.core.overrides', 'numpy.core.records', 'numpy.core.shape_base', 'numpy.core.umath', 'numpy.ctypeslib', 'numpy.fft', 'numpy.fft._pocketfft', 'numpy.fft._pocketfft_internal', 'numpy.fft.helper', 'numpy.lib', 'numpy.lib._datasource', 'numpy.lib._iotools', 'numpy.lib._version', 'numpy.lib.arraypad', 'numpy.lib.arraysetops', 'numpy.lib.arrayterator', 'numpy.lib.format', 'numpy.lib.function_base', 'numpy.lib.histograms', 'numpy.lib.index_tricks', 'numpy.lib.mixins', 'numpy.lib.nanfunctions', 'numpy.lib.npyio', 'numpy.lib.polynomial', 'numpy.lib.scimath', 'numpy.lib.shape_base', 'numpy.lib.stride_tricks', 'numpy.lib.twodim_base', 'numpy.lib.type_check', 'numpy.lib.ufunclike', 'numpy.lib.utils', 'numpy.linalg', 'numpy.linalg._umath_linalg', 'numpy.linalg.linalg', 'numpy.ma', 'numpy.ma.core', 'numpy.ma.extras', 'numpy.matrixlib', 'numpy.matrixlib.defmatrix', 'numpy.polynomial', 'numpy.polynomial._polybase', 'numpy.polynomial.chebyshev', 'numpy.polynomial.hermite', 'numpy.polynomial.hermite_e', 'numpy.polynomial.laguerre', 'numpy.polynomial.legendre', 'numpy.polynomial.polynomial', 'numpy.polynomial.polyutils', 'numpy.random', 'numpy.random._bounded_integers', 'numpy.random._common', 'numpy.random._generator', 'numpy.random._mt19937', 'numpy.random._pcg64', 'numpy.random._philox', 'numpy.random._pickle', 'numpy.random._sfc64', 'numpy.random.bit_generator', 'numpy.random.mtrand', 'numpy.version', 'packaging', 'packaging.about', 'packaging._structures', 'packaging.version', 'pickle', 'pkgutil', 'platform', 'random', 'secrets', 'select', 'selectors', 'socket', 'stackprinter', 'stackprinter.colorschemes', 'stackprinter.extraction', 'stackprinter.formatting', 'stackprinter.frame_formatting', 'stackprinter.prettyprinting', 'stackprinter.source_inspection', 'stackprinter.tracing', 'stackprinter.utils', 'struct', 'textwrap', 'thonny.plugins.backend', 'thonny.plugins.backend.birdseye_backend', 'thonny.plugins.backend.dock_user_windows_backend', 'thonny.plugins.backend.flask_backend', 'thonny.plugins.backend.matplotlib_backend', 'thonny.plugins.backend.pgzero_backend', 'thonnycontrib', 'thonnycontrib.backend'] 19:50:14.816 INFO thonny: TIME/MODS 0.000 Sending message ProgramOutput 19:50:14.816 INFO thonny: TIME/MODS 0.000 After loading plugins 19:50:14.816 INFO thonny: TIME/MODS 0.000 Beginning of mainloop 19:50:14.816 INFO thonny: TIME/MODS 0.000 Before Run 19:50:14.816 INFO thonny: TIME/MODS 0.000 Starting _execute_file 19:50:14.816 INFO thonny: TIME/MODS 0.000 Done preprocessing 19:50:14.816 INFO thonny: TIME/MODS 0.000 Done creating executor 19:50:14.816 INFO thonny: TIME/MODS 0.000 Before preparing the executor 19:50:14.816 INFO thonny: TIME/MODS 0.000 After compiling ast in executor

What should I do about this problem?

villares commented 3 months ago

Hi @ilhamfs7, thanks for reaching out with this issue, I hope I can help.

You mentioned:

I downloaded thonny-py5mode in manage packages/manage plugins.

If you install the py5 library yourself on Thonny (which I recommend when getting "standard" Thonny from https://thonny.org) you should use the Manage Packages.. panel from Thonny's Tools menu.

On the other hand, all plug-ins (like thonny-py5mode) should only be installed with the Manage plug-ins... panel, from the same menu.

From the path I saw on your message containing ...thonny-4-with-py5-windows-portable... it looks like you have downloaded a portable version of Thonny with py5 that should have worked out of the box, without you needing to install anything else, so I would really like to understand what might have happened!

One thing that I have seen previously was a conflict with libraries installed by a "standard", non-portable, Thonny (maybe installed with the installer from the Thonny site) before downloading and using the portable. So I have these questions:

One possible solution in both cases might be to try and remove the folder C:\Users\<your username>\AppData\Roaming\Python\Python310\site-packages if one exists.

Another thing I'd like to ask is if you are using the latest version of the portable-Thonny from: https://github.com/villares/thonny-portable-with-py5/releases/download/2024-07-13/thonny-414-with-py5-windows-portable.zip

I'll wait for more information from you!

ilhamfs7 commented 3 months ago

I have tried to install standard thonny from Thonny.org; i have tried to install the .exe and the portable one. When i have finished install it in my laptop, it doesnt have any issue. But, after I tried to install thonny-py5mode, my issue appeared. It applies to every single version of Thonny that I install, even the newest version of Thonny with Python 5, the standard one, or even the portable one in Thonny.org. For the second hypothesis, I think its not the problem because my issue appears when I install the py5mode in Thonny.

Oh, this issue appear after i reinstall my windows because of some problem. But, before i reinstall my windows, this issue doesnt appear.

villares commented 3 months ago

Hi @ilhamfs7,

I'm sorry you are having this issues.

From your last message I understand that you have tried standard Thonny from thonny.org and the portable. I'm still thinking the conflict may be triggered by two different sets of libraries conflicting, some from earlier install attempts.

Please try this:

ilhamfs7 commented 3 months ago

Thankyou for the instruction, but i've tried it and the problem is still the same. Can you guess if this problem is because of my laptop? or because I installed the thonny-py5mode?

villares commented 3 months ago

Can you guess if this problem is because of my laptop? or because I installed the thonny-py5mode?

I really don't know what the problem is. But I want to help you. If you uninstall the plug-in from Thonny, can you run py5 sketches with the "module mode" style?

import py5

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

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

py5.run_sketch()

If this works, we can try other ways of running "imported mode" style sketches without the plug-in, as a workaround for your problem while we don't know enough to fix it.

hx2A commented 3 months ago

I'd like to help also. I'm concerned about this:

File "C:\Users\muhil\Thonny\thonny-4-with-py5-windows-portable\lib\site-packages\jpype_init.py", line 18, in
import _jpype
ImportError: DLL load failed while importing _jpype: The specified module could not be found.

If you can't import jpype, there might be something wrong with the Java Runtime Environment it is using. Can you try this:

import jpype

jpype.startJVM()

Does that work?

ilhamfs7 commented 3 months ago

I'm sorry for my late response, for @villares suggestion, i'm sorry i dont know what is "module mode" style, is it the default style one? like this : Screenshot (6) If it is like that, then it cannot. But if not, can you tell me where "module mode" style is? I apologize for my ignorance

For @hx2A suggestion, i've try it, and the result is like this : Screenshot (5) Was that my main reason for the problem?

villares commented 3 months ago

Great! Thanks for spotting the jpype import failure @hx2A !

Yes, @ilhamfs7, this is exactly "module mode" style. And you don't have to apologize about not knowing anything about this. We are here to help as best as we can, and sometimes we fail to understand things too.

From the initial state, as @hx2A spotted, jpype was not being found. From your last message and current state, py5 library is not being found.

So I'd ask you to try:

ilhamfs7 commented 3 months ago

I have tried it, but before install py5 from Tools > Manage Packages, i got this message : image

But i can still download the py5, and after that, i tried import py5 in the console and press enter, but the result is like this : image

villares commented 3 months ago

Very interesting! I have never seen an error like this. py5 needs jpype, and it looks like jpype install failed, so py5 install failed.

Now I have two ideas:

  1. Try to install jpype1 (notice the 1) from the Manage Packages..., if it works, maybe re-install py5 too?

And we see how it goes. Otherwise... and maybe this is wiser because avoids other broken things:

  1. We start over... Delete "portable" Thonny, delete the C:\Users\muhil\AppData\Roaming\Python folder and we start again fresh from installing plain Thonny again from Thonny.org. Then install py5 from Manage Packages...

What do you think?

ilhamfs7 commented 3 months ago

I have tried the first idea, but jpype1 has been installed in the portable one. And when i tried the second one, i had to uninstall the portable thonny and python in Roaming, and then i installed thonny.exe from Thonny.org and install py5 from Manage Packages. But same as before, when i search py5, i get this message : image

What do I have to do next?

villares commented 3 months ago

I think this could be an issue with Thonny, I really don't know. I'm going to ask for help at a Thonny group. Let's see if @tabreturn and @hx2A have more ideas.

Meanwhile, could you please try the https://py5coding.org full install instructions with a conda env? you'd need to install miniconda, that is a scientific Python distribution and manager for isolated Python environments (very useful to avoid conflicts between projects). Then we can do more ideas like: Using another IDE or Jupyter Lab that is nice or even trying to point Thonny to use the conda env...

ilhamfs7 commented 3 months ago

Alright, thank you so much for the instruction and all the help; I'm going to try it.

ilhamfs7 commented 3 months ago

Hello, i want to confirm that my problem have been solved. It's because i didn't install Anaconda/Miniconda in my laptop, but after i installed it, my py5-thonnymode can be used. I apologize if this problem makes you dizzy, which turns out to be only because I didn't install anaconda/miniconda, Thank you for all the responses

villares commented 3 months ago

Cheers @ilhamfs7! I'm glad it worked in the end for you. No apologies needed!

I'm still confused on what might have gone wrong... you shouldn't have to have anaconda/miniconda to use py5 on Thonny portable or otherwise... I'll keep an eye on this.

hx2A commented 3 months ago

Thanks for letting us know, @ilhamfs7 ! Have fun coding with py5!