aferrero2707 / gimp-appimage

174 stars 17 forks source link

Python plugins crash gimp (aborted) #15

Open rcspam opened 6 years ago

rcspam commented 6 years ago

Python plugins produced this issue:

Traceback (most recent call last):
  File "********************.py", line 28, in <module>
    from gimpfu import *
  File "/tmp/.mount_8hYxRn/usr/lib/gimp/2.0/python/gimpfu.py", line 76, in <module>
    import gimp
ImportError: /tmp/.mount_8hYxRn/usr/lib/gimp/2.0/python/gimp.so: undefined symbol: PyUnicodeUCS2_SetDefaultEncoding
bin/gimp.bin: LibGimpBase-AVERTISSEMENT: gimp.bin: gimp_wire_read(): error
aferrero2707 commented 6 years ago

Could you tell me which Linux distribution you are using, and the Python versions you have installed?

Thanks!

rcspam commented 6 years ago

Ubuntu 16.04 - Python 2.7.12 and python 3.5.2

rcspam commented 6 years ago

If i pass a 'env PYTHONPATH='/tmp/.gimp-appimage/lib/gimp/2.0/python' to the appimage, it doesn't crash but it doesn't care about the pyplug...

aferrero2707 commented 6 years ago

I am trying to run the appimage on the same system and with the same python versions, but I cannot reproduce your issue.

I have tried both the Filters/Enhance/Sharpen by synthesis and the Filters/Decor/Fog plug-ins.

Which python plug-in is responsible of the crash in your case? Could you try those two and see if they work for you as well? Are you using plug-ins that are installed under $HOME/.config?

Thanks!

rcspam commented 6 years ago

Yes, this one installed in $HOME/.config... They are copied automatically by gimp-2.10. All this python plugins worked well on 2.9.... Is it possible that old py plugins with "register()" not well advise are 'the problem' ?

rcspam commented 6 years ago

As an example, this one octavesimple.py create this issue..

#!/usr/bin/env python

from gimpfu import *

def SimpleOctaveSharpening(img, drw):

    radius = 0.5
    amount = 5.0
    opacity = 100.0
    threshold = 0.0
    loops = 4
    layermode = VALUE_MODE

    pdb.gimp_image_undo_group_start(img)

    # Add a new empty base layer

    OctBase = gimp.Layer(img, "Octave Sharpened Layer", img.width, img.height, RGB_IMAGE, 100, layermode )
    img.add_layer(OctBase, -1)

    # create 4 sharpened layers and merge them to the base

    while loops > 0:
        temp_layer = drw.copy(True)
        temp_layer.mode = layermode
        img.add_layer(temp_layer, -1)
        pdb.plug_in_unsharp_mask(img, temp_layer, radius, amount, threshold)
        pdb.gimp_layer_set_opacity(temp_layer, opacity)
        OctBase = pdb.gimp_image_merge_down(img, temp_layer, 0)
        OctBase.mode = layermode
        loops = loops -1
        radius = radius * 2
        opacity = opacity / 2.0

    pdb.gimp_image_undo_group_end(img)
    gimp.displays_flush

register(
        "SimpleOctaveSharpening",
        "Octave sharpening",
        "",
        "Rolf Steinort <info@meetgimp.org>",
        "public domain",
        "2009",
        "<Image>/Filters/Enhance/Octave Sharpening Simple",
        "RGB*, GRAY*",
        [],
        [],
        SimpleOctaveSharpening)

main()
rcspam commented 6 years ago

After remove the ~/.config/GIMP-AppImageI and the first run i have to remove all the plug-ins with this kind of register() from the local plug-ins folder (these ones are copied from old local config gimp folder automatically during the first run), if not the second run crash.

aferrero2707 commented 6 years ago

Thanks for the example, I will use it to test a possible fix.

As far a I see, phyton plug-ins that are included in the AppImage bundle work correctly, while those saved under ~/.config/GIMP-AppImage don't.

aferrero2707 commented 6 years ago

I have noticed that the octave sharpening plugin fails to load due to the interpreter definition in the first line: #!/usr/bin/env python

If I remove this line, or I replace it with #!python, the plug-in is recongnized and works properly.

This is because the /usr/bin/env invocation forces the code to "go out" of the AppImage environment, while the plug-in should be run inside of it.

Could you try to delete this line and test the plug-in again?

Thanks!

rcspam commented 6 years ago

Oh yes... thats ok for me, Just a little sed -i 's#/usr/bin/env python#python#g' *.py in the directory after copy all old py-plugs is sufficient.. Thanks. It it possible to launch a shell script to execute 'sed' in the appimage to solve this issue once and for all ?