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
Try:
import PIL.Image
rather than:
import Image
Zope has an Image module and you could be encountering a namespace clash.
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
精彩评论