【发布时间】:2015-03-13 06:40:27
【问题描述】:
我正在尝试将我的 wkhtmltopdf 软件包升级到 0.12.2.1 并且没有任何运气。
- 在更新之前它确实有效。我试图更新的原因是 修复 PDF 页面之间内容的拆分。
- 我正在运行 - Ubuntu 64x - 值得信赖
- 我正在通过 python-pdfkit 使用。
- 我开始获取最新版本的
wkhtmltopdfhttp://sourceforge.net/projects/wkhtmltopdf/files/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb/download?use_mirror=hivelocity
以下是我到目前为止所做/尝试过的事情。有没有人幸运地更新了他们的设置?或者任何指针都会有很大帮助!谢谢!
开箱即用,我得到了Configuration Error,我硬编码只是为了通过这个。
# -*- coding: utf-8 -*-
import subprocess
import sys
class Configuration(object):
def __init__(self, wkhtmltopdf='', meta_tag_prefix='pdfkit-'):
self.meta_tag_prefix = meta_tag_prefix
self.wkhtmltopdf = wkhtmltopdf
if not self.wkhtmltopdf:
if sys.platform == 'win32':
self.wkhtmltopdf = subprocess.Popen( ['where', 'wkhtmltopdf'], stdout=subprocess.PIPE).communicate()[0].strip()
else:
self.wkhtmltopdf = subprocess.Popen( ['which', 'wkhtmltopdf'], stdout=subprocess.PIPE).communicate()[0].strip()
try:
#with open(self.wkhtmltopdf) as f:
with open("/usr/local/bin/wkhtmltopdf") as f:
pass
except IOError:
raise IOError('No wkhtmltopdf executable found: "%s"\n'
'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' % self.wkhtmltopdf)
现在我收到此错误,不知道如何继续。我尝试将shell=True 添加到上面的 Popen 中,但这也不起作用。
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/rq/worker.py", line 543, in perform_job
rv = job.perform()
File "/usr/local/lib/python2.7/dist-packages/rq/job.py", line 490, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/home/worker-1/Desktop/Dropbox/changeaddress/facts/jobs.py", line 864, in job_sharepdfs
mymovepdf_link = build_mymovepdf(account_uuid, addresschange_uuid)
File "/home/worker-1/Desktop/Dropbox/changeaddress/facts/jobs.py", line 608, in build_mymovepdf
s3file = pdfkit.from_string( output.getvalue() , False )
File "/usr/local/lib/python2.7/dist-packages/pdfkit/api.py", line 68, in from_string
return r.to_pdf(output_path)
File "/usr/local/lib/python2.7/dist-packages/pdfkit/pdfkit.py", line 93, in to_pdf
stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
【问题讨论】:
标签: python wkhtmltopdf pdfkit