我尝试在我的windows8机器上安装pdfkit Python API。我遇到了与path相关的问题。
Traceback (most recent call last):
File "C:\Python27\pdfcre", line 13, in <module>
pdfkit.from_url('http://google.com', 'out.pdf')
File "C:\Python27\lib\site-packages\pdfkit\api.py", line 22, in from_url
configuration=configuration)
File "C:\Python27\lib\site-packages\pdfkit\pdfkit.py", line 38, in __init__
self.configuration = (Configuration() if configuration is None
File "C:\Python27\lib\site-packages\pdfkit\configuration.py", line 27, in __init__
'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)
IOError: No wkhtmltopdf executable found: ""
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有人在windows机器上安装了Python PDFKIt吗?如何解决此错误。
我的示例代码:
import pdfkit
import os
config = pdfkit.configuration(wkhtmltopdf='C:\\Python27\\wkhtmltopdf\bin\\wkhtmltopdf.exe')
pdfkit.from_url('http://google.com', 'out.pdf')发布于 2015-09-05 00:26:54
无需修改windows环境变量即可执行以下操作:
import pdfkit
path_wkhtmltopdf = r'C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
pdfkit.from_url("http://google.com", "out.pdf", configuration=config)当然,假设路径是正确的(例如,在我的例子中是r'C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe')。
发布于 2015-11-11 14:31:48
请使用以下命令安装wkhtmltopdf
sudo apt install -y wkhtmltopdf对于windows计算机,请从以下链接安装它:http://wkhtmltopdf.org/downloads.html
并且您需要将wkhtmltopdf路径添加到环境变量中
发布于 2017-03-08 17:48:42
IOError: 'No wkhtmltopdf executable found'
确保您的$PATH中有wkhtmltopdf或通过自定义配置设置。Windows中的where wkhtmltopdf或Linux上的which wkhtmltopdf应返回二进制的实际路径。
添加以下配置行对我有效:
config = pdfkit.configuration(wkhtmltopdf="C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe")
pdfkit.from_string(html, 'MyPDF.pdf', configuration=config)似乎您需要将configuration=config作为参数进行传递。
https://stackoverflow.com/questions/27673870
复制相似问题