0

Ubuntu variant here but now the question in Apple OS X

$ "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -o out.pdf *.pdf
env: python: No such file or directory

How can I resolve error about Python after upgrading to the latest OS X?

3

2 Answers 2

2

Three of Apple's Automator actions call on python2, despite Apple removing it. They won't run under python3 without modification.

1. Install python2.
The scripts call env python, so you can install python2 direct from python.org (you'll also need to pip pyobjc).

2. Use Apple's own Quick Action "Create PDF" to Combine PDFs.
This works well for combining PDFs in the Finder, but if you want to use the action as part of an Automator workflow, consider Shortcuts.app instead, whose PDF actions don't use python.

3. Use an updated python3 script for PDF manipulation.

I've produced (better) python3 scripts for a range of PDF manipulation, including concatenation, and a grid.

https://github.com/benwiggy/PDFsuite/tree/master/Python3

You can include them in Automator or Shortcut.app's Run Shell Script action, which offers any installed languages. (Select "Pass Input as Arguments")

Again, if you install python3, you'll need to pip3 pyobjc to get the necessary ObjC bridge library.

0
$ head -5 '/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py'
#! /usr/bin/env python
#
# join
#   Joing pages from a a collection of PDF files into a single PDF file.
#

So Apple removed python but forgot to update Automator actions. Might be worth a bug report.

Until it is fixed you may want to install Python 2 manually (from source probably, doesn't seem to available via Homebrew any longer).

PS: There are two more actions with the same problem:

$ grep -l '/usr/bin/env python' /System/Library/Automator/*.action/Contents/Resources/*.py
/System/Library/Automator/Add Grid to PDF Documents.action/Contents/Resources/graphpaper.py
/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py
/System/Library/Automator/Extract Odd & Even Pages.action/Contents/Resources/extract.py
6
  • The scripts flag errors in python3.
    – benwiggy
    May 10 at 13:31
  • @benwiggy Oh my... Thanks for checking.
    – nohillside
    May 10 at 13:34
  • Ah, and it seems that Homebrew doesn't offer Python 2 any longer.
    – nohillside
    May 10 at 13:34
  • 1
    MacPorts still does. And of course you can get an installer from python.org. May 10 at 13:36
  • Incidentally, that typo in line 4 has been there since Snow Leopard at least.
    – benwiggy
    May 10 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .