0
votes

My Jenkins is using python 2.7 to execute python scripts. But I want to execute the script using python 3.7. So far I have done something like this.

test.py

#!/home/sam/python/python3/bin/python3.8
import sys

print(sys.version)

I am executing this script with python test.py. In output I am getting python version 2.6. Can anyone suggest how can I run the python script with python 3.7 path.

1
The shebang will only be honored if the script is launched like test.py, and NOT python test.py. You need to use python3 test.py (or /full/path/to/python3 test.py).0x5453
Jenkins is launching the script like "python test.py".sam

1 Answers

0
votes

If you want to select versions per command, you can use command line options like these:

py -2 my_file.py
py -3 my_file.py
py -2.7 my_file.py
py -3.4 my_file.py