2025/12/07(日) [n年前の日記]
#1 [gimp] Python-Fuで使えるモジュールを一覧表示
GIMP上の Python console で help("modules") と打ち込むと、同梱されているモジュールの一覧を表示してくれる。らしい。
_GIMP 3.0 Python Plugins - Justin's Blog
そんなことができるのか…。知らなかった。Windows11 x64 25H2 + GIMP 3.0.4 Portable Rev 2 で打ってみたら、以下が表示された。
cairo がある…。ということは cairo を使ってキッチリと描画するプラグインも作れそうかな…。
アレ? tkiniter という文字列もあるぞ? もしかして入ってたの? import できるのかな…?
エラーになる…。どゆこと? 実際に入ってるわけではないモジュールも並んでるということなのかな…。
この場合、Python から Tk を呼び出すための Pythonスクリプトは入ってるけれど、Tk の DLL自体は入ってないから呼び出せないということだろうか?
でもまあ、help("modules") と打てば、Python-Fu でどんなモジュールが使えそうか、ざっと調べることはできそう。
余談。GIMP 2.10.38 Portable で同じことをしたら、pathlib が入ってなかった。pathlib が標準モジュールとして導入されたのは Python 3.4 かららしい。GIMP 2.10 までは Python 2.7 が使われてるから、入ってないのだろうな…。
_GIMP 3.0 Python Plugins - Justin's Blog
そんなことができるのか…。知らなかった。Windows11 x64 25H2 + GIMP 3.0.4 Portable Rev 2 で打ってみたら、以下が表示された。
GIMP 3.0.4 Python Console
Python 3.12.10 (main, Apr 18 2025, 06:12:22) [GCC UCRT Clang 20.1.3 64 bit (AMD64)]
>>> help("modules")
Please wait a moment while I gather a list of all available modules...
__future__ _tracemalloc hmac secrets
__hello__ _typing html select
__phello__ _uuid http selectors
_abc _warnings idlelib setuptools
_aix_support _weakref imaplib shelve
_ast _weakrefset imath shlex
_asyncio _winapi imathnumpy shutil
_bisect _xxinterpchannels imghdr signal
_blake2 _xxsubinterpreters importlib site
_bz2 _xxtestfuzz importlib_metadata smartypants
_codecs _zoneinfo inflect smtplib
_codecs_cn abc inspect sndhdr
_codecs_hk aifc io socket
_codecs_iso2022 antigravity ipaddress socketserver
_codecs_jp argparse itertools sqlite3
_codecs_kr array jinja2 sre_compile
_codecs_tw ast json sre_constants
_collections asyncio keyword sre_parse
_collections_abc atexit lib2to3 ssl
_compat_pickle audioop libxml2 stat
_compression autocommand libxml2mod statistics
_contextvars backports linecache string
_csv base64 locale stringprep
_ctypes bdb logging struct
_ctypes_test binascii lzma subprocess
_curses bisect mailbox sunau
_datetime builtins mailcap symtable
_decimal bz2 mako sys
_distutils_hack cProfile markdown sysconfig
_elementtree cairo markupsafe tabnanny
_functools calendar marshal tarfile
_hashlib cgi math telnetlib
_heapq cgitb mesonbuild tempfile
_imp chunk mimetypes test
_io cmath mmap textwrap
_json cmd modulefinder this
_locale code more_itertools threading
_lsprof codecs msilib time
_lzma codeop msvcrt timeit
_markupbase collections multiprocessing tkinter
_md5 colorsys netrc token
_msi compileall nntplib tokenize
_multibytecodec concurrent nt tomli
_multiprocessing configparser ntpath tomllib
_opcode contextlib nturl2path trace
_operator contextvars numbers traceback
_osx_support copy opcode tracemalloc
_overlapped copyreg operator tty
_pickle crypt optparse turtle
_py_abc csv os turtledemo
_pydatetime ctypes packaging typeguard
_pydecimal curses pathlib types
_pyio dataclasses pdb typing
_pylong datetime pickle typing_extensions
_queue dbm pickletools typogrify
_random decimal pipes unicodedata
_sha1 difflib pkg_resources unittest
_sha2 dis pkgutil urllib
_sha3 doctest platform uu
_signal drv_libxml2 platformdirs uuid
_sitebuiltins email plistlib venv
_socket encodings poplib warnings
_sqlite3 ensurepip posixpath wave
_sre enum pprint weakref
_ssl errno profile webbrowser
_stat faulthandler pstats wheel
_statistics filecmp pty winreg
_string fileinput py_compile winsound
_strptime fnmatch pyclbr wsgiref
_struct fractions pyconsole xdrlib
_symtable ftplib pydoc xml
_sysconfigdata__win32_ functools pydoc_data xmlrpc
_testbuffer gc pyexpat xxlimited
_testcapi genericpath pygments xxlimited_35
_testclinic getopt pygtkcompat xxsubtype
_testconsole getpass python-console zipapp
_testimportmultiple gettext queue zipfile
_testinternalcapi gi quopri zipimport
_testmultiphase gidocgen random zipp
_testsinglephase glob re zlib
_thread graphlib reprlib zoneinfo
_threading_local gzip rlcompleter
_tkinter hashlib runpy
_tokenize heapq sched
Enter any module name to get more help. Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".
cairo がある…。ということは cairo を使ってキッチリと描画するプラグインも作れそうかな…。
アレ? tkiniter という文字列もあるぞ? もしかして入ってたの? import できるのかな…?
>>> import tkinter as tk
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "D:\Prog\Gimp-3.0.4-Portable_Rev_2\GIMPPortable\App\gimp\lib\python3.12\tkinter\__init__.py", line 38, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
^^^^^^^^^^^^^^^
ImportError: DLL load failed while importing _tkinter: 指定されたモジュールが見つかりません。
エラーになる…。どゆこと? 実際に入ってるわけではないモジュールも並んでるということなのかな…。
この場合、Python から Tk を呼び出すための Pythonスクリプトは入ってるけれど、Tk の DLL自体は入ってないから呼び出せないということだろうか?
でもまあ、help("modules") と打てば、Python-Fu でどんなモジュールが使えそうか、ざっと調べることはできそう。
余談。GIMP 2.10.38 Portable で同じことをしたら、pathlib が入ってなかった。pathlib が標準モジュールとして導入されたのは Python 3.4 かららしい。GIMP 2.10 までは Python 2.7 が使われてるから、入ってないのだろうな…。
[ ツッコむ ]
以上です。