我需要帮助来执行在 Mac OS 上使用 GIMP 库的自制 python 脚本。
我确定脚本没问题,因为它在 GNU-Linux 操作系统上运行良好。
我做了什么:
.dmg
安装 GIMP分销~/Library/Application
Support/GIMP/2.8/plug-ins
chmod +x myScript.py
.bash_profile
添加 export PYTHONHOME='/Library/Frameworks/Python.framework/Versions/2.7'
当我尝试从终端执行脚本时,我得到:
ImportError: No module named gimpfu
我不知道如何解决这个问题!
最佳答案
gimpfu
仅在从 Gimp 启动脚本时可用。有两种情况:
gimp -idf --batch-interpreter python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import batch;batch.run("./images")' -b 'pdb.gimp_quit(1)'
在哪里:
sys.path=["."]+sys.path
(这里使用当前目录)。您可以改为永久扩展通用 Python 路径。 import batch
(假定脚本位于 ./batch.py
中)注意单引号和双引号,一些用于 Python,一些用于您的 shell 解释器。
请注意,像您一样直接从命令行调用脚本有一些优点,此时会捕获许多(但不是全部...)语法错误,您不必等待 Gimp 开始找出这些错误.
关于python - 在 Mac OS 上执行 Python GIMP 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44305243/