Automator: `command not found` (Python script for command line)
Most likely, you need to tell Automator's shell instance where to locate the program jupytext.  Unless you saved jupytext somewhere specific on your hard drive, my guess is that the full path to jupytext is going to be /usr/local/bin/jupytext.  However, you can retrieve its location by opening up Terminal and using the command:

which jupytext


which will return the file path to the program.

Then, in your Automator action, replace jupytext with its full path, e.g.:

for f in "$@"; do
    /usr/local/bin/jupytext --to notebook "$f"
done