I am getting the below error while running python script as cronjob. But its working while executing manually.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/pdfkit/configuration.py", line 21, in __init__
with open(self.wkhtmltopdf) as f:
FileNotFoundError: [Errno 2] No such file or directory: b''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/aws_security_cost_audit.py", line 626, in <module>
File "/home/ubuntu/aws_security_cost_audit.py", line 621, in main
File "/home/ubuntu/aws_security_cost_audit.py", line 95, in html_to_pdf
File "/usr/local/lib/python3.4/dist-packages/pdfkit/api.py", line 47, in from_file
configuration=configuration, cover_first=cover_first)
File "/usr/local/lib/python3.4/dist-packages/pdfkit/pdfkit.py", line 42, in __init__
self.configuration = (Configuration() if configuration is None
File "/usr/local/lib/python3.4/dist-packages/pdfkit/configuration.py", line 27, in __init__
'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)
OSError: No wkhtmltopdf executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
The file /usr/local/bin/wkhtmltopdf
is executable and paths are exported by default.
root@jump-box:/home/ubuntu# whereis wkhtmltopdf
wkhtmltopdf: /usr/local/bin/wkhtmltopdf
root@jump-box:/home/ubuntu# which wkhtmltopdf
/usr/local/bin/wkhtmltopdf
root@jump-box:/home/ubuntu# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Any guess on what could be the issue?
If I add this job:
* * * * * echo $PATH >> /ws/tmp.log 2>&1
then:
> cat tmp.log
/usr/bin:/bin
So you probably want to wrap your cronjob in a script that sets up the environment properly