【发布时间】:2020-04-09 16:32:19
【问题描述】:
在将 python 脚本作为 cronjob 运行时出现以下错误。但它在手动执行时工作。
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
文件/usr/local/bin/wkhtmltopdf是可执行文件,默认导出路径。
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
你猜猜可能是什么问题?
【问题讨论】:
-
看起来
self.wkhtmltopdf是一个空字节串......现在为什么会这样,应该是什么,没有更多信息我们无法判断。也许minimal reproducible example 可以提供帮助?
标签: python ubuntu cron ubuntu-14.04 wkhtmltopdf