nook
nook

Reputation: 1884

Running python script with python3 using ./

How do I run a python script with python 3.7 by using this syntax: ./main.py?

By default, it runs with python 2.7 and thus I'm forced to run the script with python3 ./main.py

I am on MacOS.

Upvotes: 0

Views: 146

Answers (1)

Mureinik
Mureinik

Reputation: 311188

You could place a shebang on the first line of the file to make it executable (by python3):

#!/usr/bin/env python3

Upvotes: 3

Related Questions