pythongimpgimpfu

GIMP_wire_read error upon adding python script in correct folder


I am trying to learn GIMP 2.10.38 with python and I don't know either that well, so I tried adding a simple python script but it doesn't show up in GIMP at all. Here is the script I added:

#!/usr/bin/env python
from gimpfu import *

def simple_plugin(image, drawable):
    gimp.message("Hello from a simple plugin!")

register(
    "python-fu-simple-plugin",
    "Simple Plugin Test",
    "A simple test plugin",
    "Your Name",
    "Your Name",
    "2024",
    "<Image>/Filters/Simple Test",  # Or any menu location
    "RGB*",
    [],
    simple_plugin,
)

main()

The script is in the correct folder - confirmed that in preferences - folders - plug-ins Searching online I came across the --verbose argument and that led me to this error:

Querying plug-in: 'C:\Users\Prafulla\AppData\Roaming\GIMP\2.10\plug-ins\simplepy.py'
gimp-2.10: LibGimpBase-WARNING: gimp-2.10: gimp_wire_read(): error

I know it is a general error related to communication within GIMP but couldn't find enough information online. I have tried a reinstall already, but not tried deleting all folders manually yet. Any idea how I should proceed?


Solution

  • Your problem isn't the "wire-read" error (which has been showing in my Gimp console for years without being related to any trouble). In the same terminal output, you should also see this:

    Traceback (most recent call last):
      File "/path/to/your/file.py", line 17, in <module>
        simple_plugin,
    TypeError: register() takes at least 11 arguments (10 given)
    

    The missing argument is the (usually empty) list of return values

    register(
        "python-fu-simple-plugin",
        "Simple Plugin Test",
        "A simple test plugin",
        "Your Name",
        "Your Name",
        "2024",
        "<Image>/Filters/Simple Test",  # Or any menu location
        "RGB*",
        [],  # <- your existing list of input values
        [],  # <- your missing list of returned values 
        simple_plugin,
    )
    

    This said this is a deprecated registration usage, in more modern times you would use:

    #!/usr/bin/env python
    from gimpfu import *
    
    def simple_plugin(image, drawable):
        gimp.message("Simple plugin, working on %s in %s" % (drawable.name,image.name))
    
    register(
        "simple-plugin",            # "python-fu" added by default anyway...
        "Simple Plugin Test",
        "A simple test plugin",
        "Your Name",
        "Your Name",
        "2025",
        "Simple Test",      # Just the menu item
        "RGB*,GRAY*",       # GRAY necessary if you want the plugin to also work on mask/Channels.
        [
            (PF_IMAGE,   'image',   'Input image',   None),   # Explicit input image (if necessary)
            (PF_DRAWABLE,'drawable','Input drawable',None),   # Explicit input drawable (if necessary)
        ],
        [],
        simple_plugin,
        menu="<Image>/Filters" # Menu location of menu item above
    )
    
    main()
    

    Where the two main differences are that: