Re: pl/pyton: exceptions.ImportError: No module named email.Parser

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Eugene Prokopiev <prokopiev(at)stc(dot)donpac(dot)ru>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: pl/pyton: exceptions.ImportError: No module named email.Parser
Date: 2005-11-27 19:34:29
Message-ID: 20051127193429.GA64790@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Andy Chambers 2005-11-27 20:19:07 PG_COMMAND_OK oid information required
Previous Message Eugene Prokopiev 2005-11-27 15:17:06 pl/pyton: exceptions.ImportError: No module named email.Parser