I wrote print('Hello world!') in the shell of Jenkins.
The error shows below:

Can anyone help with the issue? Thanks
You are NOT executing python program in the given screenshot, instead you are executing a shell script. It's evident from the error screenshot where it states executable as
[python] $ /bin/sh -xe /tmp/jenkinsxxxxxxxxx.sh
python is the name of your jenkins host (and job too looking at your logs), presumably you are confused with that. Try following instead
echo "Hello world"
and it'll print alright. Basically any and every shell script command will work just fine.
python --versionpython --versionit returns: python2.7.18; typepython3 --versionit returns python3.7.7