Search code examples
pythondjangoxhtml2pdf

Django > xhtml2pdf > Getting it to work?


I'm having problems understanding how I should install xhtml2pdf. I have followed the instructions at Chris Glass's site and have a virtual environment setup and have run unit tests. When I insert the following at the top of my views.py file:

import ho.pisa as pisa
import cStringIO as StringIO
import cgi
import os

I get an error saying No module named ho.pisa (which I expected). How do I get django or even the python command line import this module (because I have tried importing the module in the command line with the same level of success).

EDIT

Why do I need a virtual enviroment. Can't I just install xhtml2pdf as a package and import it normally or will I break some Django/python thing?

EDIT

I have also run django from inside the xhtml2pdf virtual enviroment > (xhtml2pdfenv)person@person-laptop:~/Software/django$ ./manage.py runserver and still it refuses to import xhtm2pdf


Solution

  • I just tried installing xhtml2pdf using pip, not the package.

    The pisa module was in xhtml2pdf, not ho

    >>> import xhtml2pdf.pisa as pisa