Executing and saving python file?


I've written a little python script for creating passwords - which i want to run for new passwords.

How do i run it and store it in a variable?

password_generator.py.zip (1.2 KB)

The first thing you will need to know is the full path to the Python interpreter which you want to use,

and the simplest approach might just be to point that to the path of a .py file.

An option on the Execute shell script action will let you copy the output to a named variable


In that event, i might have programmed it wrong. Beause currently it does not return anything, if i do what you suggest :sweat_smile:

Are you sure you have the right path to your python interpreter ?

And when you say 'does not return anything', are you looking in the randomPassword variable ?

In Terminal.app, to get a viable path, try one of these commands (depending on whether you want to use Python 2.7 or Python 3, which will need to have been installed by you)

which python


which python3

This, for example :

  • using a command substitution to obtain a valid path to a Python interpreter
  • and writing a Python source file (similar to yours) to Desktop from a variable

is working here.

password by python.kmmacros (3.5 KB)

1 Like