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?

nohillside
  • 100,768
hhh
  • 3,904
  • Please make the question stand on its own, without expecting people to follow links to understand the full picture (but in that case here I'm not even sure the link is necessary at all). – nohillside May 10 '22 at 12:41
  • Are you looking to report this to apple or install missing software so their actions work? https://apple.stackexchange.com/a/439473/5472 – bmike May 10 '22 at 14:32
  • https://gist.github.com/jnotwell/9c1f02249b00115a4b5b3196adfea0e7 – nohillside May 11 '22 at 06:32

2 Answers2

3

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.

benwiggy
  • 35,635
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
nohillside
  • 100,768