Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
gimpfu not detected by pylance
#1
Hi, I'm pretty new to gimp plugins, and I wanted to play around with developing some specific plugins for my project. When I run vscode, however, pylance does not detect gimpfu. That's weird, since my interpreter is set to the python version in GIMP's bin. Additionally, the plugins do work when I run them in the application, so gimpfu exists somewhere. But without any familiarity with the documentation, developing kind of feels kinda blind... Undecided

GIMP version: 2.10
Python path: C:\Program Files\GIMP 2\bin\python.exe

Is there any way I can fix or troubleshoot this problem? I'm not sure where to start. I'm trying to see if gimpfu can work in WSL, if that works I can just move the plugins over to Windows. Thanks in advance.
Reply
#2
Gimpfu only exists in the Gimp environment. It has a cascade of import dependencies (see /usr/lib/gimp/2.0/python/, and some of them are binaries (.so in Linux, likely .dll in windows) and these need an environment set up by Gimp to import correctly. Maybe you can copy the python files and remove a few imports to at least have an importable source for your IDE (never tried, I use a plain editor).

In any case this will only help with auto-completion, because the plugin has to run in a python module started by Gimp, so it won't run in your debug environment for instance.

This said, debugging under Linux is a lot easier than debugging under Windows because if you start Gimp from a command prompt, all messages from Gimp and the plugins appear in the command prompt.

Also see: Debugging python-fu scripts in Windows (which despite its title contains hints that are also useful on Linux/WSL)
Reply
#3
(10-24-2023, 07:39 AM)Ofnuts Wrote: Gimpfu only exists in the Gimp environment. It has a cascade of import dependencies (see /usr/lib/gimp/2.0/python/, and some of them are binaries (.so in Linux, likely .dll in windows) and these need an environment set up by Gimp to import correctly. Maybe you can copy the python files and remove a few imports to at least have an importable source for your IDE (never tried, I use a plain editor).

In any case this will only help with auto-completion, because the plugin has to run in a python module started by Gimp, so it won't run in your debug environment for instance.

This said, debugging under Linux is a lot easier than debugging under Windows because if you start Gimp from a command prompt, all messages from Gimp and the plugins appear in the command prompt.

Also see: Debugging python-fu scripts in Windows (which despite its title contains hints that are also useful on Linux/WSL)

Thanks for the reply, yes auto-completion, typing and linting are really the main things I'm looking for in development, rather than debugging. I just want to make stuff quickly and test it in Gimp.

One thing I tried was copy the files from C:\Program Files\GIMP 2\lib\gimp\2.0\python over to my plugins site. This helped with some autocompletion, but certain variables like PDB_INT8, PDB_INT16 etc, and various methods from pdb don't show up. I suspect this is because these files are compiled in pyd format, but I don't know how to decompile compiled python code, and I've read decompiling is a difficult task.

I'll see if plain Ubuntu will support this, or try other versions of Gimp, but these seem to carry their own issues in stackexchange.. Is there any place where I can view the python source code? I think it would be easiest if I just copy and paste the source code in my working directory, and let pylance figure it out.
Reply
#4
Essentially the same problem on Ubuntu.

Source code is here: https://gitlab.gnome.org/GNOME/gimp/-/tr...ins/pygimp
Reply
#5
(10-26-2023, 07:47 AM)Ofnuts Wrote: Essentially the same problem on Ubuntu.

Source code is here: https://gitlab.gnome.org/GNOME/gimp/-/tr...ins/pygimp

I see. Appreciate the confirmation!
Reply
#6
I have exactly the same problem.
Can you tell me how you solved it? What did you do exactly?
Reply


Forum Jump: