X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7EAB5DC699 for ; Sun, 27 Nov 2005 15:34:35 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14083-06 for ; Sun, 27 Nov 2005 15:34:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id CFE9ADC63B for ; Sun, 27 Nov 2005 15:34:32 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id jARJYUGr063519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 27 Nov 2005 12:34:32 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id jARJYTM8064904; Sun, 27 Nov 2005 12:34:29 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id jARJYTOR064903; Sun, 27 Nov 2005 12:34:29 -0700 (MST) (envelope-from mfuhr) Date: Sun, 27 Nov 2005 12:34:29 -0700 From: Michael Fuhr To: Eugene Prokopiev Cc: pgsql-interfaces@postgresql.org Subject: Re: pl/pyton: exceptions.ImportError: No module named email.Parser Message-ID: <20051127193429.GA64790@winnie.fuhr.org> References: <4389CDF2.6020805@stc.donpac.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4389CDF2.6020805@stc.donpac.ru> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[AWL=0.000] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/65 X-Sequence-Number: 5861 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