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 test_srt.py
script, taking Chapter2.wav
as its input and redirecting its output to Chapter2.srt
. (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
#!/usr/local/bin/python3
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
#!/usr/local/bin/python3
you can run it from the Terminal without specifying the language on the command line. Like this:
cd vosk-api/python/example
test_srt.py /Users/Shared/Chapter2.wav > /Users/Shared/Chapter2.srt
So now we come to where my knowledge runs out. When you say
In KM generally I get away with below path
#!/usr/local/bin/python3
I don’t know what you mean. Is that line at the start of your test_srt.py
file? Are you copying the contents of test_srt.py
, 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:
- What is the output of
which python3
?
- 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.