IOError:wkhtmltopdf以非零代码退出1.错误:[空白]

时间:2016-01-12 23:57:29

标签: python ubuntu-12.04 wkhtmltopdf

我一直在尝试使用pdfkit / wkhtmltopdf,但是当我使用它时,我得到以下错误,最后的错误为空白:

 File "email_app.py", line 118, in <module>
    send_mail()
  File "email_app.py", line 114, in send_mail
    RECEIPT_UNITS_YTD, RECEIPT_COST_YTD, RECEIPT_UNITS_MONTH_YOY, RECEIPT_COST_MONTH_YOY, RECEIPT_UNITS_YTD_YOY, RECEIPT_COST_YTD_YOY)
  File "/local/scripts/algos.py", line 1321, in no_issue
    pdfkit.from_file('/local/scripts/file'+VENDOR_ID+'.html','VendorScorecard_'+VENDOR_ID+'.pdf',cover='/local/scripts/cover'+VENDOR_ID+'.html')
  File "/usr/local/lib/python2.7/dist-packages/pdfkit/api.py", line 46, in from_file
    return r.to_pdf(output_path)
  File "/usr/local/lib/python2.7/dist-packages/pdfkit/pdfkit.py", line 119, in to_pdf
    raise IOError("wkhtmltopdf exited with non-zero code {0}. error:\n{1}".format(exit_code, stderr.decode("utf-8")))
IOError: wkhtmltopdf exited with non-zero code 1. error:

此外,您还可以看到调用pdfkit.from_file的代码片段:

f = open("file"+VENDOR_ID+".html","w")
cover = open("cover"+VENDOR_ID+".html","w")
email = open("email"+VENDOR_ID+".html","w")
email_body = email.write(text+no_issues)
asin_det = f.write(asin)
t = cover.write(body)
f.close()
cover.close()
email.close()
pdfkit.from_file('/local/scripts/file'+VENDOR_ID+'.html','VendorScorecard_'+VENDOR_ID+'.pdf',cover='/local/scripts/cover'+VENDOR_ID+'.html')

我已经在互联网上搜索了一个答案,但大多数人都建议我需要安装xvfb,我已经完成了。事实上,如果我只是运行wkhtmltopdf http://www.google.com output.pdf,它就像一个魅力。我在使用Ubuntu 12.04的Linux上。

当我在Windows桌面上运行完全相同的代码时,它按预期工作 - 吐出一个非常漂亮的PDF。

0 个答案:

没有答案