"Reportlab Version 2.1+ is needed!" --import error

5,209 views
Skip to first unread message

mcc...@gmail.com

unread,
Feb 20, 2014, 1:34:32 PM2/20/14
to xhtm...@googlegroups.com
Hi, 

I'm using working on a django / mezzanine / cartridge project.  The author of cartridge thought it might be a problem with the Pisa library.  Any suggestions? Thanks! 

When I try to generate a PDF of an invoice, I receive this error:

"Reportlab Version 2.1+ is needed!"

I have Reportlab 3.0 installed.

I'm working in a clean virtualenv. This is my pip freeze:

Cartridge==0.9.2
Django==1.6.2
Mezzanine==3.0.9
PIL==1.1.7
Pillow==2.3.0
bleach==1.4
feedparser==5.1.3
filebrowser-safe==0.3.2
future==0.9.0
grappelli-safe==0.3.6
html5lib==1.0b3
oauthlib==0.6.1
pisa==3.0.33
pyPdf==1.13
pytz==2013.9
reportlab==3.0
requests==2.2.1
requests-oauthlib==0.4.0
six==1.5.2
sphinx-me==0.2.1
tzlocal==1.0
wsgiref==0.1.2
xhtml2pdf==0.0.5

Marius Gedminas

unread,
Feb 21, 2014, 4:18:21 AM2/21/14
to mcc...@gmail.com, xhtm...@googlegroups.com
On Thu, Feb 20, 2014 at 10:34:32AM -0800, mcc...@gmail.com wrote:
> I'm using working on a django / mezzanine / cartridge project. The author
> of cartridge thought it might be a problem with the Pisa library. Any
> suggestions? Thanks!
>
> When I try to generate a PDF of an invoice, I receive this error:
>
> "Reportlab Version 2.1+ is needed!"
>
> I have Reportlab 3.0 installed.

Do you have a full traceback?

Marius Gedminas
--
Include me out.
signature.asc

animesh...@gmail.com

unread,
Feb 21, 2014, 4:30:54 AM2/21/14
to xhtm...@googlegroups.com
The problem is with the installation.
The __init__ checks for a variable REPORTLAB22. This is imported from util.py.
The code in util.py is using the following logic

if not (reportlab.Version[0] == "2" and reportlab.Version[2] >= "1"):
  raise ImportError("Reportlab Version 2.1+ is needed!")

REPORTLAB22 = (reportlab.Version[0] == "2" and reportlab.Version[2] >= "2")

This will fail as the reportlab version is now 3.0.

Just replace this code segment with the following:

if not (reportlab.Version[:3]>="2.1"):

  raise ImportError("Reportlab Version 2.1+ is needed!")

REPORTLAB22 = (reportlab.Version[:3]>="2.1")

and reinstall xhtml2pdf. It will work.

You will need to uninstall xhtml2pdf first.

I am new to google groups and thus, pardon is I have not followed some norms.

Regards,

Animesh

mcc...@gmail.com

unread,
Feb 21, 2014, 8:54:36 AM2/21/14
to xhtm...@googlegroups.com
That worked.  Thank you for your help! 

fyi: for anyone who happens on this post:  I actually am using the older  Pisa 3.033 package, and I went in and changed it to your code.  

My folders are as follows:  /ENV2/lib/python2.7/site-packages/sx/pisa3/pisa_util.py

Tom Brander

unread,
Feb 27, 2014, 7:06:13 PM2/27/14
to xhtm...@googlegroups.com
Had a similar problem And applied the suggested patch anyhow assuming that the reportlab version was the issue, but did not get the error message but same line fail

However I'm trying to run Python 3 I think that Pisa may not be P3 usable??
Getting: 
Exception Value:
invalid syntax (__init__.py, line 43)
Exception Location:/home/tom/myvenv3/lib/python3.3/site-packages/ho/pisa/__init__.py in <module>, line 26
Python Executable:/home/tom/myvenv3/bin/python
Python Version:3.3.2

Rajan Quixom

unread,
Aug 1, 2016, 2:52:27 AM8/1/16
to Pisa XHTML2PDF Support
Reply all
Reply to author
Forward
0 new messages