Can't create pdf using python PDFKIT Error : “ No wkhtmltopdf executable found:”

前端 未结 10 1951
灰色年华
灰色年华 2020-12-01 06:37

I tried installing pdfkit Python API in my windows 8 machine. I\'m getting issues related to path.

Traceback (most recent call last):
  File \"C:\\Python27\\         


        
10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 07:08

    IOError: 'No wkhtmltopdf executable found'

    Make sure that you have wkhtmltopdf in your $PATH or set via custom configuration. where wkhtmltopdf in Windows or which wkhtmltopdf on Linux should return actual path to binary.

    Adding this configuration line worked for me:

    config = pdfkit.configuration(wkhtmltopdf="C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe")
    pdfkit.from_string(html, 'MyPDF.pdf', configuration=config)
    

    From github

    Seems you need to pass configuration=config as argument.

提交回复
热议问题