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
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
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
#!/usr/bin/env python3
cheers thanks.. – bbartling Jun 30 '20 at 13:31try/except
retrieves data from a sensor, and anothertry/except
retrieves data from weather API. The weather API works just fine but the my sensor reading isnt... But when running the same .py file (that CRON is using) thru terminal it all works just fine... – bbartling Jun 30 '20 at 13:33crontab
. – Seamus Jun 30 '20 at 13:35