Re: pl/pyton: exceptions.ImportError: No module named email.Parser - Mailing list pgsql-interfaces

From Michael Fuhr
Subject Re: pl/pyton: exceptions.ImportError: No module named email.Parser
Date
Msg-id 20051127193429.GA64790@winnie.fuhr.org
Whole thread Raw
In response to pl/pyton: exceptions.ImportError: No module named email.Parser  (Eugene Prokopiev <prokopiev@stc.donpac.ru>)
Responses Re: pl/pyton: exceptions.ImportError: No module named  (Eugene Prokopiev <prokopiev@stc.donpac.ru>)
List pgsql-interfaces
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


pgsql-interfaces by date:

Previous
From: Eugene Prokopiev
Date:
Subject: pl/pyton: exceptions.ImportError: No module named email.Parser
Next
From: Andy Chambers
Date:
Subject: PG_COMMAND_OK oid information required