Perl programmer for hire: download my resume (PDF).
John Bokma's Hacking & Hiking

How to make Python scripts work in the Gimp on Ubuntu 18.10

February 22, 2019

Today, I suddenly got an insight as to why a Python script I had written was not working in the Gimp running on Ubuntu 18.10: maybe I had to install additional support for Python. And indeed, if you install the GNU Image Manipulation Program via the command line as follows:

sudo apt-get install -y gimp

Python support is not installed, and hence Python scripts won't work in the Gimp.

The Python script I was trying to make work in the Gimp was written for a customer way back in 2009. So I was not really surprised when he reported to me that it wasn't working on Ubuntu 18.10. The Python script uses Resynthesizer, a Gimp plug-in for texture synthesis. Given a sample of a texture, it can create more of that texture. The Python script I wrote just makes it possible to process a directory of textures and create a large number of new ones in another directory by repeatedly calling the Resynthesizer plug-in.

I had installed the Resynthesizer plug-in as follows:

sudo apt-get install -y gimp-resynthesizer

The odd thing is that this plug-in also requires Python for some of its functionality. Yet it doesn't have Gimp Python support as a dependency. One can see this issue by running the Gimp via the command line. It will report (at least) 8 times:

gimp: LibGimpBase-WARNING: gimp: gimp_wire_read(): error

And it's no coincidence that the Resynthesizer plug-in installs exactly 8 Python scripts in /usr/lib/gimp/2.0/plug-ins.

So when I also noticed that there was no Python-Fu entry in the Filters menu of the Gimp I wondered if the installation was missing Python support. And indeed, apt-cache search gimp | grep python reported amongst others:

gimp-python - Python scripting support for GIMP

So I installed Python support as follows:

sudo apt-get install -y gimp-python

And finally, after I quit and started the Gimp again my script showed up under the correct menu entry. Also, the Python-Fu entry under Filters was now available.