Domanda

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

È stato utile?

Soluzione

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

The pisa module was in xhtml2pdf, not ho

>>> import xhtml2pdf.pisa as pisa

Altri suggerimenti

Right. I got it to work by doing the following after step 5 of the development enviroment at Chris Glass's site:

$ python setup.py install
# navigate to you django project
$ cd ../django
$ ./manage.py runserver

The import line from xhtml2pdf import pisa in views.py does not raise any errors any more

You can install pisa by following line:

easy_install pisa
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top