This might be a work around. I've tried it and it works quite well for me. You may use the "/bin/bash" script and execute the python3 script inside it. Use the "cat <<EOF" instead of a real file so as to not create an extra file. Here is an example
query=$1
cat <<EOF | /usr/bin/python3
import sys
query = "${query}"
# do something here
...
result = ...
sys.stdout.write(result)
EOF