pythongimppython-fugimpfu

python can't import gimpfu


I'm trying to write a gimp script using pythonfu. However, when I try to run script locally, I get an error

`--> ./vvv.py
Traceback (most recent call last):
  File "./vvv.py", line 5, in <module>
    from gimpfu import *
ImportError: No module named gimpfu

I gather that the script might be only loadable through gimp. However, the script doesn't appear at gimp menus. In that case, how do I get the error output?


Solution

  • depending on your os, you have to look for GIMP plugin's directory, something like:

    GIMP 2\lib\gimp\2.0\plug-ins 
    

    and copy your script there. Of Course you have to add registration stuff something like this:

    register(
        "python-fu-draw",                                #<- this is plugin name
        N_("brief"),                                     #<- description
        "Long",                                          #<- description
        "name surname",                                  #<- author
        "@Copyright 2013",                               #<- copyright info
        "2013/10/29",                                    #<- creation date
        N_("_Draw..."),                                  #<- label shown in gimp's menu
        "",  #<- kind of image requested from your script (INDEX,RGB,...and so on)
        [                                                #<- input parameters array
            (PF_FILE, "ifile", N_("Color input file"), 'default.txt'),
    ],
    [],                                                  #<- output parameters array (usually empty)
    draw,                                                #<- main method to call 
    menu="<Image>/Filters/",                             #<- Where add your plugin
    domain=("gimp20-python", gimp.locale_directory) 
    )
    
    main()                                               #<- don't forget this
    

    Once you copied the script into right directory with right registration stuff you can run GIMP and run your script selecting it in drop down menu you selected in registration stuff. You don't have to run it from a python console. So those wouldn't work:

    python myscript.py
    ./myscript.py
    >>> myscript
    

    To debug your script interactively open a python-fu console from gimp:

    Filters->Python-fu->Console
    

    Take a look at this web site. Mainly slides are very useful.

    While if you want to run your script in a batch mode please take a look at this