pdfkit-python:';str';对象没有属性解码

pdfkit-python:';str';对象没有属性解码,python,pdfkit,Python,Pdfkit,我正在尝试使用pdfkit将字符串html转换为pdf文件。这就是我正在做的 try: options = { 'page-size': 'A4', 'margin-top': '0.75in', 'margin-right': '0.75in', 'margin-bottom': '0.75in', 'margin-left': '0.75in',

我正在尝试使用pdfkit将字符串html转换为pdf文件。这就是我正在做的

  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))

但是,在
from_string
中,我得到异常'str'对象没有属性decode。关于如何解决这个问题有什么建议吗?我正在使用Python 3.5.1

尝试用以下内容替换配置行-二进制文件的路径作为字节对象提供:

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

参考:

但它给了我一个错误:wkhtmltopdf报告了一个错误:由于网络错误,以代码1退出:ConnectionRefusedError