Reputation: 519
I need help to execute a home made python script that use GIMP libraries on Mac OS. I'm sure the script is ok because it works well on GNU-Linux OS.
What I did:
.dmg
distribution ~/Library/Application
Support/GIMP/2.8/plug-ins
chmod +x myScript.py
.bash_profile
adding export PYTHONHOME='/Library/Frameworks/Python.framework/Versions/2.7'
When I try to execute the script from terminal I get:
ImportError: No module named gimpfu
I don't know how to fix this!
Upvotes: 4
Views: 1530
Reputation: 8904
gimpfu
is only available when the script is launched from Gimp. There are two cases:
The script is a regular plugin, it should contains at least a call to register(...) and a call to main(). This identifies it to Gimp and it can be called from the Gimp UI. Note that the best place to keep it in the plug-ins directory in your Gimp profile, and not the Gimp installation directories. Since you are on OSX, I recommend that you keep the Python file in a directory that you can access easily (and that you backup) and add a soft link to it in your Gimp profile.
The script is just a script to be used in batch mode, it doesn't need to be in the plug-ins directory, it must still be called from Gimp which is done by calling Gimp and passing the script as parameters, with a command line such as:
gimp -idf --batch-interpreter python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import batch;batch.run("./images")' -b 'pdb.gimp_quit(1)'
Where:
sys.path=["."]+sys.path
(here the current directory is used). You can possibly extend the general Python path permanently instead.import batch
(script is assumed to be in ./batch.py
)Mind the single and double quotes, some for Python, some for your shell interpreter.
Note that calling the script directly from the command line as you did has some merit, many (but not all...) syntax errors are caught at this point, and you don't have to wait for Gimp to start to find these out.
Upvotes: 5