Robert Johnstone
Robert Johnstone

Reputation: 5371

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

Upvotes: 2

Views: 13570

Answers (4)

jatinkumar patel
jatinkumar patel

Reputation: 2990

You can install pisa by following line:

easy_install pisa

Upvotes: 0

Robert Johnstone
Robert Johnstone

Reputation: 5371

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

Upvotes: 0

Alasdair
Alasdair

Reputation: 308809

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

The pisa module was in xhtml2pdf, not ho

>>> import xhtml2pdf.pisa as pisa

Upvotes: 8

Related Questions