Python Script not working after 12.3 Update


Long time lurker, first time poster. Thanks to all that post such valuable information here, it's been an amazing resource for my learning and building of my own macros.

I have a set of macros that use python scripts to call an API for a web service, passing KM variables to the script and returning results. They're written in python 2.7, as the API is in python 2.7.

My primary work machine is on 10.4, but I know that Apple removed Python 2.7 as a default framework in the Monterey 12.3 update, so I updated my laptop to see if/how I could continue to use these scripts.

As expected, they broke, but after installing python 2.7 using the installer on, i'm able to run my scripts in terminal and they work, but they fail to run in the keyboard maestro execute shell script action. I'm assuming this is due to an incorrect entry in the /usr/bin/env file, but i'm not sure how to fix it.

Here's one of the scripts:

#!/usr/bin/env python
import sys
import os
from interdubs_api import Interdubs
IDX_PATH            = ''
IDX_KEY             = 'APIKEY'
idx = Interdubs(IDX_PATH, IDX_KEY)
loginlist = idx.list_logins()
for l in loginlist:
	print l['name']

If anyone comes across this and is as clueless as me, I was able to get my script working by calling python from the installed path.


Hey Evan,

Keyboard Maestro does not use any of the user set-up files, so the native path is very sparse.

See: Path in Shell Scripts

You can create an ENV_PATH variable in Keyboard Maestro to work around this, but keep in mind that sometimes Python environments have other needs as well.


1 Like