tags:

views:

39

answers:

2

I have installed the Image module http://www.pythonware.com/products/pil/. I then try and import it in the python interpreter and successfully so:

>>> import Image
>>> 

But when I try to import the module in Zope via DTML page:

DTML page looks like:

<dtml-var import_image>

Which calls this script:

def import_image(self):
    import Image
    im = Image.open("/home/rv/Desktop/blah.jpg")
    return im

I then get this error:

"ImportError: No module named Image" How can there be no module when I can import it in the python interpreter?


EDIT

The python script is in Zopes extension folder

+1  A: 

You can’t just import any module in zope python script. Zope has some security restrictions. In your case you need create external method in %zope-instance%/Extensions

OR maybe your zope instance cannot find this library because it's running in another python environment. You should check if all parameters are right in %zope-instance%/bin/zopectl

Alex M
the file is in my extensions folder
Phil
A: 

Try:

import PIL.Image

rather than:

import Image

Zope has an Image module and you could be encountering a namespace clash.

tomvon