问题描述
config = pdfkit.configuration(wkhtmltopdf=r"/usr/local/lib/python3.6/site-packages/pdfkit/configuration.py")
pdfkit.from_file(html_name,pdf_name)
if os.path.exists(pdf_name):
print(pdf_name)
当我手动运行脚本时,效果很好,但是当脚本以cron
开始时,会出现此错误:
pdfkit.from_file(html_name,pdf_name)
File "/usr/local/lib/python3.6/site-packages/pdfkit/api.py",line 49,in from_file
return r.to_pdf(output_path)
File "/usr/local/lib/python3.6/site-packages/pdfkit/pdfkit.py",line 153,in to_pdf
'https://github.com/JazzCore/python-pdfkit/wiki/Using-wkhtmltopdf-without-X-server' % stderr)
OSError: wkhtmltopdf: cannot connect to X server
You will need to run wkhtmltopdf within a "virtual" X server.
Go to the link below for more information
https://github.com/JazzCore/python-pdfkit/wiki/Using-wkhtmltopdf-without-X-server
有帮助吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)