I'm trying to run an external python script from Godot using the OS.execute command but it's kind of buggy and runs different python versions than on my terminal (zsh).
My code in Godot:
var output = []
exit_code = OS.execute("python", ["fetch.py"], true, output)
print(">exit_code: " + str(exit_code))
That code didn't work and after some debugging I found that it didn't recognise f-strings, a feature added in Python3.6, which lead me to believe that it runs Python2.7 or anything lower than 3.6, so I tried python3
instead of python
but this didn't even run the fetch.py and just returned exit_code 1. Moreover, if I type python --version
or python3 --version
in the terminal, it returns Python 3.9.0
. If I try the same thing in Godot, python --version
returns nothing, and python3 --version
returns Python 3.8.2
.
This has me really confused and I've been struggling with this for a while. I've tried creating aliases in .zshrc, .bash_profile thinking maybe OS.execute() runs from bash, but no success. Does anyone know how I can fix this or where exactly Godot's OS.execute() gets its commands from/what it actually runs low level? I use MacOS v11.1 Big Sur.