Need help importing/installing reportlab module

A

Active8

I did this once and can't remember how <blush> so I read the
reportlab user guid. It says to unzip the reportlab archive - this
is on w2k, BTW, with Python23 - to a directory and make a file
called reportlab.pth in the pythod dir. The only line in this file
is supposed to be the path to the reportlib dir.

Then I'm instructed to open the ... ok I'll close and reopen ... the
python cmd line interpreter and type

import reportlab

so I get

Import Error: no module named reportlab

not too surprizing since I can't find anything named reportlab in
the archive. I did basically the same thing to install PIL and that
worked. I did also download rl_win32_2_3 and move those .pyd files
to the pythod dll dir - I assume a pyd is a python dll - worked for
PIL.

If anyone can help me straighten this out, I'd really apppreciate
it.

TIA
 
S

Steve Holden

Active8 said:
I did this once and can't remember how <blush> so I read the
reportlab user guid. It says to unzip the reportlab archive - this
is on w2k, BTW, with Python23 - to a directory and make a file
called reportlab.pth in the pythod dir. The only line in this file
is supposed to be the path to the reportlib dir.
When you unpack the ReportLab archive (I downloaded ReportLab_1_19.zip)
it creates a reportlab-1_19 directory (in my case in the C:\Steve
directory), with a reportlab subdirectory that is the package you want
to import.

My Python is installed in C:\Python23, so I created a
C:\Python23\reportlab.pth file which contained the single line

C:\Steve\reportlab-1_19

Lo! "import reportlab" now works, and you should be good to go.

Then I'm instructed to open the ... ok I'll close and reopen ... the
python cmd line interpreter and type

import reportlab

so I get

Import Error: no module named reportlab

not too surprizing since I can't find anything named reportlab in
the archive. I did basically the same thing to install PIL and that
worked. I did also download rl_win32_2_3 and move those .pyd files
to the pythod dll dir - I assume a pyd is a python dll - worked for
PIL.
I'd be rather concerned that you can't find "reportlab" in the archive.
Basically all it contains is a "reportlab" package directory with the
code in it.
If anyone can help me straighten this out, I'd really apppreciate
it.

TIA

Well if this doesn't fix it, please let me know.

regards
Steve
[ReportLab's US rep]
 
A

Active8

When you unpack the ReportLab archive (I downloaded ReportLab_1_19.zip)
it creates a reportlab-1_19 directory (in my case in the C:\Steve
directory), with a reportlab subdirectory that is the package you want
to import.

My Python is installed in C:\Python23, so I created a
C:\Python23\reportlab.pth file which contained the single line

C:\Steve\reportlab-1_19

Lo! "import reportlab" now works, and you should be good to go.

I'd be rather concerned that you can't find "reportlab" in the archive.
Basically all it contains is a "reportlab" package directory with the
code in it.
That's what I see, just no .py or other files named reportlab.
Well if this doesn't fix it, please let me know.
when I unzip, I get

..\ReportLab_1_19\reportlab-1_19

which contains manifest.txt and the reportlab dir where the actual
python code is. I've tried putting both subdirs under d:\ and
changed the reportlab.pth path accordingly. I've changed the .pth
file from DOS to unix and back because I read somewhere that the
line termination char musst be just so - and I'm not even sure I got
that right, but there's a newline in there. I even tried it without
a newline.

I've tried forward and backslashes. Also tried running
test_pdfgen_general.py from the command line and the python
interpreter - can't type "d:\report* because python doesn't like
colons - ..\report* - it doesn't like dots, either. But when I run
it from the windows command line, it says that in

line 12 of test_pdfgen_general.py

from reportlab.test import unittest
Import Error: no module named reportlab.test

But I checked that test\ dir and unittest.py is there. If that's a
clue, I don't know what to make of it.

I recall installing another module - maybe PIL. When I tried that
from x import y thing, I got an error, but the next instruction was
to just type import PIL or whatever, and that didn't throw any
errors.

I'm pretty confused that it worked so well for you and isn't for me.
The instructions can't be simpler.
 
S

Steve Holden

Active8 said:
On Mon, 30 Aug 2004 23:24:08 -0400, Steve Holden wrote:
[...how to install ReportLab's open source code...]
That's what I see, just no .py or other files named reportlab.
Aha. The magic word is "package". See below.
when I unzip, I get

..\ReportLab_1_19\reportlab-1_19
Right, but this is because you chose to unzip INTO a directory you had
created called ReportLab_1_19. If you look at the archive with WinZip or
similar, you'll see that it essentially bundles everything into a
reportlab-1_19 directory. That directory contains only two things: you
identify them in your next bit. Not sure what the "..\" is doing in your
path up there ...
which contains manifest.txt and the reportlab dir where the actual
python code is. I've tried putting both subdirs under d:\ and
changed the reportlab.pth path accordingly. I've changed the .pth
file from DOS to unix and back because I read somewhere that the
line termination char musst be just so - and I'm not even sure I got
that right, but there's a newline in there. I even tried it without
a newline.
Right. You are complicating things WAY beyond what they need to.
Something I am prone to do myself, so I feel a certain sympathy.

Delete everything you've done so far and unpack the archive into the
root directory on your D: drive. (or move what you have already, if you
feel confident doing that and you haven't messed about with the contents
of the package). This will create

D:\reportlab-1_19\MANIFEST.txt
D:\reportlab-1_19\reportlab\__init__.py

and a whole bunch of other stuff. What you are supposed to import is the
D:\reportlab-1_19\reportlab DIRECTORY: it's a package, as indicated by
the presence of the __init__.py file.

So, having got this far, you now need to create a .pth file that Python
will find (the easiest way to ensure that is to create it in the same
directory as your python.exe interpreter binary). It doesn't matter what
it's called, as long as its name ends in ".pth". It needs to contain
just one line, which reads

D:\reportlab-1_19

This will indicate to the interpreter that it can look in that directory
for the reportlab package, and bingo, you are done.

Note that if you install multiple packages you can add a line to the
same .pth file for each of the packages you want Python to find, but
that needn't concern you just now.
I've tried forward and backslashes. Also tried running
test_pdfgen_general.py from the command line and the python
interpreter - can't type "d:\report* because python doesn't like
colons - ..\report* - it doesn't like dots, either. But when I run
it from the windows command line, it says that in

line 12 of test_pdfgen_general.py

from reportlab.test import unittest
Import Error: no module named reportlab.test
If you can't import reportlab, what makes you think you'll be able to
import one of its sub-packages? :^)
But I checked that test\ dir and unittest.py is there. If that's a
clue, I don't know what to make of it.

I recall installing another module - maybe PIL. When I tried that
from x import y thing, I got an error, but the next instruction was
to just type import PIL or whatever, and that didn't throw any
errors.

I'm pretty confused that it worked so well for you and isn't for me.
The instructions can't be simpler.
Basically you are just being confused by the extra directory level
you've added, plus lack of knowledge about packages, which will be a bit
confusing until you've seen one in action.

I don't think it helps that packages aren't well-described in the
mainstream documentation, and I would encourage you to read the
description in the tutorial [Section 6.4 in my 2.3 documentation]. It
also doesn't really help that type(reportlab) is reported as <type
'module'>, adding to the potential for confusion, but once you have used
packages for a while it seems like a very natural way to bundle related
pieces of functionality.

Get back to the group again if you still can't import reportlab - it's
really worth the effort, honest! I use the o-s toolkit to do all my
invoicing.

regards
Steve
 
A

Active8

On Tue, 31 Aug 2004 07:52:32 -0400, Steve Holden wrote:

Right, but this is because you chose to unzip INTO a directory you had
created called ReportLab_1_19.

Actually, that's one of the context menu options winrar suggests -
the name of the zip file.
If you look at the archive with WinZip or
similar, you'll see that it essentially bundles everything into a
reportlab-1_19 directory. That directory contains only two things: you
identify them in your next bit. Not sure what the "..\" is doing in your
path up there ...

Sorry, should have been "." IOW I unzipped it into the dir it was
saved in and let winrar create a dir named after the zip archive.
Right. You are complicating things WAY beyond what they need to.
Something I am prone to do myself, so I feel a certain sympathy.

As it says at your site, Python folks are nice - liked the success
matrix bit, too :) i.e., the "...two ways into..." article linked
from the home page.
Delete everything you've done so far and unpack the archive into the
root directory on your D: drive. (or move what you have already, if you
feel confident doing that and you haven't messed about with the contents
of the package). This will create

D:\reportlab-1_19\MANIFEST.txt
D:\reportlab-1_19\reportlab\__init__.py
Done

and a whole bunch of other stuff. What you are supposed to import is the
D:\reportlab-1_19\reportlab DIRECTORY: it's a package, as indicated by
the presence of the __init__.py file.

So, having got this far, you now need to create a .pth file that Python
will find (the easiest way to ensure that is to create it in the same
directory as your python.exe interpreter binary). It doesn't matter what
it's called, as long as its name ends in ".pth". It needs to contain
just one line, which reads

D:\reportlab-1_19

Done. Even tried D:\reportlab-1_19\reportlab after the above line
failed - just in case. Erm... I just shut down and started python
again and it reread the path file and works. Screw myself :( Recall
I mentioned shutting it down once before? Maybe I didn't do that
often enough. Wish I knew, cause this has been what I'd call a PITA
compared to the last time I installed this package.
This will indicate to the interpreter that it can look in that directory
for the reportlab package, and bingo, you are done.

Mekes sense. Python finds what is now paths.pth in the same dir as
its executable, etc.
Note that if you install multiple packages you can add a line to the
same .pth file for each of the packages you want Python to find, but
that needn't concern you just now.

Maybe not, but it'll save a post later.

[...] and I would encourage you to read the
description in the tutorial [Section 6.4 in my 2.3 documentation]. It
also doesn't really help that type(reportlab) is reported as <type
'module'>, adding to the potential for confusion, but once you have used
packages for a while it seems like a very natural way to bundle related
pieces of functionality.

Agreed and duly noted. How can I forget after this? ;)

But the userguide.pdf has bullets and paragraphs in that section and
I'm sure you're not talking about graphics_reference.pdf. THe report
lab site I downloaded from... sparse. I didn't see add'l docs there.

From 00readme.txt
"
If you don't see the pdf manual you expected or you wich to
ensure an up to date copy run the script tools/genAll.py!
"
genALL.py is not in tools\, it's in docs\ - where the readme resides
:) heh, heh... documentation's a bitch.

test_pdfgen_general.py seems to work nicely. runAll.py throws no
errors and compiles __init__.py, unittest.py, and utils.py.

genAll.py threw a flurry of messages some WARNs some Errors. I tried
to redirect win console errors to a file, but all those python
errors don't make it there. The first wrning was that the Imaging
Library was not available. Unable to import bitmaps.

Maybe that means PIL? I dunno.

I got graphics_reference.pdf out of the deal. Not sure if there
should be more, but the 00readme says

"
Thid directory holds documentation. For end users,
it should contain a number of PDF manuals. For
people working with the source, this directory will
be the destination for any manuals built.
"
Get back to the group again if you still can't import reportlab - it's
really worth the effort, honest! I use the o-s toolkit to do all my
invoicing.

Is that part of reportlab or what? FYI, reportlab is used by a
program called gerber2pdf by Joseph C Chavez. It converts the
industry standard Gerber files from an electronic circuitboard
layout package to pdfs. Kinda handy when you don't have a high $
photoplotter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top