On Thu, Nov 15, 2018 at 09:24:10AM +0100, Martin Sukany wrote:
> Hi,
> 
> you'd fix this by defining PATH variable in your crontab, or specify the
> full path to python3 interpreter instead using env.
> 
> M>
> 
> 

As the others said, and to expand, it is probably from the shebang line of your
python script which you should not change. You just want cron to not use it. So
in short in yourscript.py the first line should be #!/usr/bin/env python3, you
should call the scipt in cron as such:

/usr/local/bin/python3 /path/to/yourscript.py

Also that would be the same way to do it in a service. The reason I say that is
the specific best solution is in case your python script has dependencies in a
.venv or a specific python version and you have multiple. So you can change the
above to be as such.

/path/to/project/.venv/bin/python /path/to/project/yourscript.py

I use that syntax for example to spawn gunicorn served microservices.

Ken

Reply via email to