pdfkit - python : 'str' object has no attribute decode
<p>I am attempting to use pdfkit to convert string html to a pdf file. This is what I am doing</p>

<pre><code>  try:
        options = {
            'page-size': 'A4',
            'margin-top': '0.75in',
            'margin-right': '0.75in',
            'margin-bottom': '0.75in',
            'margin-left': '0.75in',
        }
        config = pdfkit.configuration(wkhtmltopdf="/usr/local/bin/wkhtmltopdf")

        str= "Hello!!"
        pdfkit.from_string(str,"Somefile.pdf",options=options,configuration=config)
        return HttpResponse("Works")

    except Exception as e:
        return HttpResponse(str(e))
</code></pre>

<p>however at <code>from_string</code> I get the exception  'str' object has no attribute decode. Any suggestions on how I can fix this ? I am using Python 3.5.1</p>

<p>Try replacing the config line with this - path to the binary is provided as a bytes object:</p>

<pre><code>config = pdfkit.configuration(wkhtmltopdf=bytes("/usr/local/bin/wkhtmltopdf", 'utf8'))
</code></pre>

<p>Reference: <a href="https://github.com/JazzCore/python-pdfkit/issues/32" rel="nofollow">https://github.com/JazzCore/python-pdfkit/issues/32</a></p>

python pdfkit