0

For CRON schedule that I am trying to run a .py file... Does the shebang at the top of a .py file need to state the version of python?

#!/usr/bin/env python

If I need Python 3, should this be: #!/usr/bin/env python3

bbartling
  • 237
  • 2
  • 14

1 Answers1

2

Yes. At least for now you need to specify either python or python3.

At some point, python a.k.a Python ver 2.7.16 may be deprecated, and removed from the Raspbian distribution. But when this will happen has been the subject of speculation for some time.

For now, python is version 2, and may be determined as follows:

$ python -V
Python 2.7.16

This, as reported on my Raspbian buster system.

python3 is the newer version of Python; its version determined as follows:

$ python3 -V
Python 3.7.3

And they are literally two separate binaries on your system:

$ which python
/usr/bin/python
$ which python3
/usr/bin/python3
Seamus
  • 23,558
  • 5
  • 42
  • 83