Yet another Can't run python thread

Hi All,
I've managed to get multiple python script working before with help from the forum where I had to define the path properly .

This time I'm stuck and I apologise in advance for silly question, as I can't figure how to invoke the script properly

What I type in terminal to run my command
cd vosk-api/python/example
python3 /Users/prashantm/vosk-api/python/example/ /Users/Shared/Chapter2.wav > /Users/Shared/

In KM generally I get away with below path

I can't figure how to run this with KM and keep getting errors.

Your examples cover two related but separate situations.

In the Terminal example, you’re telling python3 (which python3? we don’t know, but we’ll figure it out soon) to run the script, taking Chapter2.wav as its input and redirecting its output to (I’m leaving out the paths for brevity.)

To know which python3 is being invoked in this command—you may have several, but only one is the default—run this in Terminal:

which python3

That will give you the full path to the python3 that successfully runs your script.

In your Keyboard Maestro example, you talk about


This is what’s commonly called the “shebang line,” and it appears as the first line of scripts that are called directly. The #! can be pronounced “sharp-bang,” which is then condensed to “shebang.” On Unix systems, the shebang line is a way of giving a script the ability to tell the system which language to run it with. So if you have a script file that starts with


you can run it from the Terminal without specifying the language on the command line. Like this:

cd vosk-api/python/example /Users/Shared/Chapter2.wav > /Users/Shared/

So now we come to where my knowledge runs out. When you say

In KM generally I get away with below path

I don’t know what you mean. Is that line at the start of your file? Are you copying the contents of, and pasting it into an Execute Shell Script action, and then pasting the shebang line at the top of that?

To get any further, we need to know a couple of things:

  1. What is the output of which python3?
  2. How are you trying to run your script from Keyboard Maestro? Here, it would help to see a screenshot of the macro or an upload of the macro itself (and the script, if it's separate from the macro). I understand if you are reluctant to do that, as there may be personal or proprietary information in the macro or script. Maybe you can redact that?

I can think of several ways in which a script can run from the Terminal but not from within Keyboard Maestro—mainly because I've had this problem many times myself. The fastest way to get to a solution is to see what you're doing that isn't working.

Sorry for the long reply. I didn't have time to write a shorter one.

The good Doctor's post is full of good advice that you should follow.

This is merely a small addendum:

If you are using an M1-based Mac and python3 was installed via brew then that path will not be correct. That path will be /opt/homebrew/bin/python3.

If you use both Intel and M1-based Macs, you might wonder "How do I avoid problems if this program is installed in different places on different Macs?"

That is an excellent question.

The answer is to use this instead:

#!/usr/bin/env python3

which will use the first python3 found in your $PATH.

To make sure the $PATH is set correctly for Keyboard Maestro, see the ENV_PATH variable entry in the Keyboard Maestro Wiki.