user2649681
user2649681

Reputation: 848

Python Gimp plugin failing to register - gimp_wire_read() error

I'm attempting to write a Python plugin for Gimp (2.10.38). Right now, it is absolutely barebones to just register the function and run main, but it is failing to register and show up in the program.

#!/usr/bin/python

from gimpfu import *

def msg(txt):
    pdb.gimp_message(txt)

msg('Running knitpc')

def knitpc(timg, tdrawable):
    pdb.gimp_message('Hello ')

register(
    'knit_pc_plugin',
    'Test plugin',
    'Test plugin',
    'Me',
    'Me',
    '2024',
    '<Image>/Image/Knit...',
    '*',
    [],
    [],
    knitpc
)

msg('Registered function')

main()

msg('Ran main')

I do not find an option for it under the Image menu, nor can I find in the Plugin Browser. Running gimp-2.10 --verbose shows the following in the console with no further information:

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

Running python knit_pc_plugin.py gives the No module named 'gimpfu' error, but does not indicate any syntax errors.

I have also tried removing the timg, tdrawable params from knitpc, which made no difference.

Upvotes: 0

Views: 94

Answers (1)

xenoid
xenoid

Reputation: 8904

  1. Shouldn't be a problem if you are on Windows, but first check that your Python support is working (you should have a working Filters > Python-fu Console). Gimp has a built-in Python support on Windows, but you can break it by installing your own Python interpreter elsewhere.

  2. Then if you look at Gimp's output (using gimp-console.exe, or starting from a terminal if using OSX or Linux), you see this:

(python2:1314703): LibGimpBase-ERROR **: 21:40:06.004: gimp_wire_write_msg: the wire protocol has not been initialized

This is because you tried to be clever by using pdb.gimp_message(). But you can't use Gimp message until a connection with Gimp has been established, which happens only after main() has run. If you replace your msg() calls by regular print instructions you'll find them in the output, and your plugin will register.

Some hints & tricks to debug Gimp scripts on Windows here.

Upvotes: 0

Related Questions