Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from weasyprint import HTML
>>> HTML('http://weasyprint.org/').write_pdf('/tmp/weasyprint-website.pdf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/weasyprint/__init__.py", line 94, in __init__
namespaceHTMLElements=False)
TypeError: parse() got an unexpected keyword argument 'override_encoding'
>>>
我相信我已经安装了所有依赖项。这是怎么回事?
答案 0 :(得分:0)
您似乎遇到与此https://github.com/Kozea/WeasyPrint/issues/353相同的问题。
可能是因为你的html5lib
已经过时了。它至少需要html5lib-1.0b9
。如果您html5lib
安装了pip
,它可能仍然是html5lib-1.0b8
。我建议你这样做更新:
pip install --pre html5lib
答案 1 :(得分:-1)
打开文件:/usr/local/lib/python2.7/dist-packages/weasyprint/ init .py
更改此代码:
result = html5lib.parse(
source, treebuilder='lxml', override_encoding=encoding,
transport_encoding=protocol_encoding,
namespaceHTMLElements=False)
对此:
result = html5lib.parse(
source, treebuilder='lxml'
)
它适用于OS X El Capitan 10.11.6(15G31)