Osascript > Applescript > Python > Shell object - execution error: suggestions?

warp1's icon

I'm trying to execute a Python script within Max, and sending a simple command to run the script (as I would do in terminal) does not work in Max when sending to the 'Shell'object. I read that another way to do this is to create an Applescript (which simply says 'do shell script /location/name of script) and use Osascript to run the Applescript and thereby the Python script. All a bit convoluted really. When I try to run this I get the following error: execution error: *** Supported version is Python 3.x.x - Install to continue! *** (1)

Can anyone point me in the right direction here? Example patch below:

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

You have to give shell asolute path of the python executable
if you want it to execute python code.
osascript is ok if you need no output from shell.

From the error one could see that script you want to run needs python 3 >
but you are calling python 2.7

warp1's icon

That makes sense. I have Python 3 on my machine, and when I run the commands in terminal it runs just fine - I'm just not sure how to target that version within Max.

Source Audio's icon

Do you target commands using python3.x in terminal ?
I also installed python 3.8 but did not remove 2.7
and also did not try to replace it as default binary.
to call it in max/shell I need to give it full path to :

/Library/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python -i
binary itself could be also copied somewhere else...

warp1's icon

I have Python3 installed with miniconda for my terminal env. So would the command to run a script look something like this in Max?

cd /applications/script_location /Library/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python ./runscript.py

Source Audio's icon

I don't know if one needs to cd for shell, or is it enough to give it python 3.8 path.
would that not be enough :

/Library/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python ./runscript.py

Source Audio's icon

I just made a quick test.
I have installed python 3.8
binary executable is in
/Library/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
I can simply send that path to shell together with script path and it works.
What also work is to copy executable to another location,
like for example Desktop.
this message :
~/Desktop/Python ~/Desktop/summy.py
to shell
runs the script summy.py which is also on Desktop