While working on a Django Web Application using Python, I recently encountered an error while using a library named xhtml2pdf. This library is a Python library for exporting xhtml to PDF.
While using it in Django Web framework for developing a hassle free web service to export customized HTML templates into PDF, I encountered some error which I had to dig into the library to find the actual problem and its solution. I noticed that this problem of "cannot import name inputstream django" was faced by many people and therefore writing this post to document it. Please note that this proposed solution is workable for Python 2.7 and hasn't been checked on Python v.3.x .
When I installed xhtml2pdf library and used it in Django Web framework, I encountered following error:
1 | importerror: cannot import name inputstream |
1 2 3 4 | File "/usr/home/username/virtualenvs/projectname/lib/python2.7/site-packages/xhtml2pdf/parser.py" , line 17, in <module> from html5lib import treebuilders, inputstream ImportError: cannot import name inputstream < /module > |
1 | $ pip install html5lib==1.0b8 |
1 | $ pip uninstall html5lib |