TypeError: parse() got an unexpected keyword argument 'override_encoding'

zachary picture zachary · Jul 20, 2016 · Viewed 8.6k times · Source
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'
>>>

I believe I have installed all the dependencies. What is going on here?

Answer

kiendang picture kiendang · Sep 20, 2016

It seems you have the same problem as this https://github.com/Kozea/WeasyPrint/issues/353.

It might be because you have a out of date html5lib. It needs to be at least html5lib-1.0b9. If you install html5lib though pip it may still be html5lib-1.0b8. I suggest you update by doing this:

pip install --pre html5lib