[reportlab-users] Reportlab compiling in Linux
Andy Robinson
andy at reportlab.com
Wed May 2 19:37:09 EDT 2007
> Traceback (most recent call last):
> File "newbars.py", line 7, in ?
> from reportlab.graphics import renderPM
> File
> "/home/davidfrank/reportlab_2_0/reportlab/build/lib/reportlab/graphics/renderPM.py",
> line 26, in ?
> raise ImportError, "No module named _renderPM\n" + \
> ImportError: No module named _renderPM
> see http://www.reportlab.org/rl_addons.html
>
> Now, seems to be that I cannot find renderPM.py though it is right there at
> /home/davidfrank/reportlab_2_0/reportlab/build/lib/reportlab/graphics/.
> The error report does tell me to go to the link,
> http://www.reportlab.org/rl_addons.html, and download the
> rl_addons.
This is actually one area where things are poorly documented. Open
source users get a bunch of building blocks, which we usually put
together for our commercial customers, and you're using optional extra
functionality.
We have a very useful script on our site here, which you should
download and run:
ftp://ftp.reportlab.com/rl_check.py
This will tell you what's installed, what isn't, and whether various
components are out of synch.
renderPM is an "optional extra" which requires an extra, large-ish C
library (_renderPM.so when built) as well as actually needing the font
files for bitmap creation. reportlab/graphics/renderPM.py is a
Python module which will always be present. To actually create a
bitmap graphic, you need to have compiled the C extension
_renderPM.so. If you get the rl_addons distribution, you can CD into
that directory and run "setup.py build" again. Then, you may need to
copy the generated _renderPM.so to be on your Python path. (If you
had rights to do the 'setup.py install', it would get installed
system-wide, but you probably don't.)
Once you have done this you should be able to execute the statement
"import _renderPM" from a Python prompt, which rl_check.py can also do
for you.
Your next issue will be that bitmaps require the font files. When we
make a PDF, it's sufficient for us to embed the string "Helvetica" in
the PDF, an Adobe Reader knows how to display it later. When making a
GIF, PNG or JPG, you really need a Helvetica font file locally. There
is a file on our site with the 'standard 14 font files' which I
suggest you unzip into reportlab/fonts; it is
ftp://ftp.reportlab.com/pfbfer.zip
We aren't comfortable including these fonts in our standard distro for
complex copyright reasons, and are looking for alternative ones we
could redistribute.
Once you get this far, you can then cd to reportlab/graphics and
execute "python renderPM.py". On my windows box I get this....
C:\code\reportlab\graphics>renderPM.py
wrote pmout\renderPM0.gif
wrote pmout\renderPM0.tif
wrote pmout\renderPM0.png
wrote pmout\renderPM0.jpg
wrote pmout\renderPM0.pct
...
and eventually an index.html page tying them together. If this
happens, you;re all sorted, and can also check the generated bitmaps
by eye.
As I said the installation of the bitmap graphics is poorly
documented, mostly due to lack of time within ReportLab (and/or lack
of volunteers to do documentation or work on build scripts within the
community! I keep hoping...) and also because few people use it for
bitmap graphics. Once upon a time we wanted to keep all the
"optional" capabilities separate. I'm coming round to the view that a
single distro which presumes a working C compiler would make
everyone's lives easier.
I hope this gets you there - bedtime has arrived in my time zone but
if you hit a dead end, post the error messages here and someone will
help in the morning.
- Andy
More information about the reportlab-users
mailing list