On Sun, Nov 27, 2005 at 06:17:06PM +0300, Eugene Prokopiev wrote:
> dbmail=# select get_header(messageblk) from dbmail_messageblks;
> ERROR: plpython: function "get_header" failed
> DETAIL: exceptions.ImportError: No module named email.Parser
Your function works here with Python 2.4.2 and PostgreSQL 8.0.4 and
8.1.0, although I had to use parser.parsestr() instead of parser.parse()
because the latter expects a file-like argument (an alternative would
be to use parse() and pass a StringIO object).
As for why the import fails, might PL/Python be using a different
version of Python than the command-line python program? What does
the following function show?
CREATE FUNCTION pyversion() RETURNS text AS $$
import sys
return sys.version + '\n' + '\n'.join(sys.path)
$$ LANGUAGE plpythonu;
Does this function show the same version and module search path as
an ordinary Python program?
python -c 'import sys; print sys.version, sys.path'
What do the following commands show?
ldd /path/to/python
ldd /path/to/plpython.so
--
Michael Fuhr