python-3.xmacospython-pdfkit

PDFKit FileNotFoundError Python


I'm trying to convert a html file to PDF using pdfkit in Python3. I'm using PyCharm with macOS Mojave and this is the error I get when trying to run the code:

   Traceback (most recent call last):
   File "/Users/cesarvargas/miniconda3/envs/test/lib/python3.6/site- 
   packages/pdfkit/configuration.py", line 21, in __init__
   with open(self.wkhtmltopdf) as f:
   FileNotFoundError: [Errno 2] No such file or directory: b''

This is the code that I'm using:

import pdfkit

if __name__ == "__main__":
    with open("test.html") as f:
        t = pdfkit.from_file(f, False)

Solution

  • I already resolved the error, installing the WKHTMLtoPDF binaries:

    https://wkhtmltopdf.org/downloads.html

    More info here:

    https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf