Automator problems with custom Python
I thought I’d implement this simple drag-and-drop PDF combiner at the office today, only to discover that it didn’t work. I made a simpler one: just the two steps “combine PDF” and “open in preview”. I noticed that the files were being created but were empty. In the console app I found the following error:
[toggle code]
-
Traceback (most recent call last):
-
File "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py", line 23, in ?
- from CoreGraphics import *
-
File "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py", line 23, in ?
- ImportError: No module named CoreGraphics
It was interesting to see that at least some Automator functionality is programmed in Python.
My problem was that, at the office, I updated Python from the 2.3 that comes with Mac OS X 10.4 to 2.4, and then I made 2.4 the default (linked /usr/bin/python to /usr/local/bin/python2.4). However, the way Python works is that libraries are installed on a per-version basis. So 2.4 had no idea where to import the core graphics library.
I switched the default Python back to 2.3 and the Automator app began working as expected.
In response to Combining multiple PDF files into a single file: Automator allows you to combine multiple PDF files into a single file.
More Automator
- Another Safari 14 Services workaround
- Another workaround to Safari 14’s Services bug is to copy the results to the clipboard.
- Renumber selected lines of text
- This very short script renumbers lines of text and normalizes on a single tab/space combination in front of each number.
- AppleScript, variables, and dropped filenames in Automator
- Automator is a simple workflow system for Mac OS X. By its nature it is very procedural: one task follows another; workflows don’t loop and they don’t store variables for later. However, this is possible in Automator and while it adds complexities it can also solve problems such as wanting to save dropped filenames for later use.
- Combining multiple PDF files into a single file
- Automator allows you to combine multiple PDF files into a single file.