python html5lib ImportError: cannot import name inputstream 解决方式 版本0.999999

By 水木神風 at 2017-08-03 • 0人收藏 • 5320人看过

python html5lib 

Traceback (most recent call last):

  File "E:\med100\api\core\global_common\interface.py", line 44, in route

    module = load_module(controller)

  File "E:\med100\api\core\global_common\interface.py", line 23, in load_module

    module = imp.load_source(controller, 'controller/%sCtrl.py' % (controller))

  File "controller/caseCtrl.py", line 9, in <module>

    from util.pdf import pdfUtil, pdf2jpg

  File "E:\med100\api\util\pdf\pdfUtil.py", line 14, in <module>

    import xhtml2pdf.pisa as pisa

  File "C:\Python27\lib\site-packages\xhtml2pdf\pisa.py", line 3, in <module>

    from xhtml2pdf.document import pisaDocument

  File "C:\Python27\lib\site-packages\xhtml2pdf\document.py", line 2, in <module>

    from xhtml2pdf.context import pisaContext

  File "C:\Python27\lib\site-packages\xhtml2pdf\context.py", line 23, in <module>

    import xhtml2pdf.parser

  File "C:\Python27\lib\site-packages\xhtml2pdf\parser.py", line 17, in <module>

    from html5lib import treebuilders, inputstream


ImportError: cannot import name inputstream


修改代码 17行:

from html5lib import treebuilders, inputstream

修改成


from html5lib import _inputstream as inputstream

3 个回复 | 最后更新于 2017-10-16
2017-08-25   #1

from html5lib import treebuilders,_inputstream as inputstream

2017-08-25   #2

安装此版本:

pip install html5lib==1.0b8

2017-10-16   #3

  File "C:\Python27\lib\site-packages\xhtml2pdf\parser.py", line 671, in pisaParser

    encoding=encoding)

  File "C:\Python27\lib\site-packages\html5lib\html5parser.py", line 235, in parse

    self._parse(stream, False, None, *args, **kwargs)

  File "C:\Python27\lib\site-packages\html5lib\html5parser.py", line 85, in _parse

    self.tokenizer = _tokenizer.HTMLTokenizer(stream, parser=self, **kwargs)

  File "C:\Python27\lib\site-packages\html5lib\_tokenizer.py", line 36, in __init__

    self.stream = HTMLInputStream(stream, **kwargs)

  File "C:\Python27\lib\site-packages\html5lib\_inputstream.py", line 151, in HTMLInputStream

    return HTMLBinaryInputStream(source, **kwargs)

TypeError: __init__() got an unexpected keyword argument 'encoding'



也能用 1.0b8版本解决

登录后方可回帖