Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 8947F1337BCF for ; Thu, 28 Apr 2011 10:15:34 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 23405-03 for ; Thu, 28 Apr 2011 13:15:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from blu0-omc1-s29.blu0.hotmail.com (blu0-omc1-s29.blu0.hotmail.com [65.55.116.40]) by mail.postgresql.org (Postfix) with ESMTP id A20031337B92 for ; Thu, 28 Apr 2011 10:15:06 -0300 (ADT) Received: from BLU142-W36 ([65.55.116.9]) by blu0-omc1-s29.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 28 Apr 2011 06:15:06 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_96d13dca-c295-4859-981e-0b72a60ec170_" X-Originating-IP: [24.34.12.246] From: Martin Gainty To: , CC: "pgsql-general@postgresql.org" Subject: Re: plpython module import errors Date: Thu, 28 Apr 2011 09:15:06 -0400 Importance: Normal In-Reply-To: <4DB9624A.1000104@compulab.co.il> References: , <4DB9624A.1000104@compulab.co.il> MIME-Version: 1.0 X-OriginalArrivalTime: 28 Apr 2011 13:15:06.0600 (UTC) FILETIME=[4AE2F680:01CC05A6] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.022 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1.929, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/979 X-Sequence-Number: 175335 --_96d13dca-c295-4859-981e-0b72a60ec170_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable you will have to compensate for python's version-i*i*t*c behaviour by namin= g the binary to the exact version of python you are calling e.g. mv python python5 (for python version 5 binary) mv python python6 (for python version 6 binary) then in each of the bash scripts you are calling reference python5 or pytho= n6 the correct version you can also setup an alias in the .bashrc to point to the 'right version' *friends dont let friends code in python* Martin=20 ______________________________________________=20 Note de d=E9ni et de confidentialit=E9 Ce message est confidentiel et peut =EAtre privil=E9gi=E9. Si vous n'=EAte= s pas le destinataire pr=E9vu=2C nous te demandons avec bont=E9 que pour sa= tisfaire informez l'exp=E9diteur. N'importe quelle diffusion non autoris=E9= e ou la copie de ceci est interdite. Ce message sert =E0 l'information seul= ement et n'aura pas n'importe quel effet l=E9galement obligatoire. =C9tant = donn=E9 que les email peuvent facilement =EAtre sujets =E0 la manipulation= =2C nous ne pouvons accepter aucune responsabilit=E9 pour le contenu fourni= . > Date: Thu=2C 28 Apr 2011 15:49:14 +0300 > From: sim@compulab.co.il > To: shreeseva.learning@gmail.com > CC: pgsql-general@postgresql.org > Subject: Re: [GENERAL] plpython module import errors >=20 > On 04/28/2011 02:19 PM=2C c k wrote: >=20 > > Hello=2C > > I have installed postgresql 9 on fedora 14 having python 2.7. Now > > created plpythonu language in my database and created a simple > > function to calculate sum of two variables. > > while importing math libbrary and executing the function i got the erro= r > > PL/Python: ImportError: No module named cmath > > > > tried to search help for this error on net and tried various things > > but nothing solved this. > > What can I do to solve this error. > > I can still work from python interpreter directly. > > Thanks in advcance. > > C P Kulkarni > This can happen if you have more then one version of python on the=20 > server and the postgresql is using a different one then you do on the=20 > command line. This is becuase modules are installed per version of python= . > The easiest way to check this is: >=20 > create or replace function pyver() returns text as > $$ > import sys > return sys.version > $$ language 'plpythonu'=3B >=20 > select pyver() > and see if the version it returns is the same one as when you open the=20 > interpreter. >=20 > Sim >=20 > --=20 > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general = --_96d13dca-c295-4859-981e-0b72a60ec170_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable you will have to compensate for python's version-i*i*t*c behaviour by namin= g the binary to the exact version of python you are calling e.g.
mv pyth= on python5 (for python version 5 binary)
mv python python6 (for python v= ersion 6 binary)

then in each of the bash scripts you are calling re= ference python5 or python6 the correct version
you can also setup an ali= as in the .bashrc to point to the 'right version'

*friends dont let = friends code in python*
Martin
_____________________________________= _________
Note de d=E9ni et de confidentialit=E9
 =3B
= Ce message est confidentiel et peut =EAtre privil=E9gi=E9. Si vous n'=EAtes= pas le destinataire pr=E9vu=2C nous te demandons avec bont=E9 que pour sat= isfaire informez l'exp=E9diteur. N'importe quelle diffusion non autoris=E9e= ou la copie de ceci est interdite. Ce message sert =E0 l'information seule= ment et n'aura pas n'importe quel effet l=E9galement obligatoire. =C9tant d= onn=E9 que les email peuvent facilement =EAtre sujets =E0 la manipulation= =2C nous ne pouvons accepter aucune responsabilit=E9 pour le contenu fourni= .




>=3B Date: Thu=2C 28 Apr 2011 15:49:14 +0300
>= =3B From: sim@compulab.co.il
>=3B To: shreeseva.learning@gmail.com
= >=3B CC: pgsql-general@postgresql.org
>=3B Subject: Re: [GENERAL] pl= python module import errors
>=3B
>=3B On 04/28/2011 02:19 PM=2C = c k wrote:
>=3B
>=3B >=3B Hello=2C
>=3B >=3B I have ins= talled postgresql 9 on fedora 14 having python 2.7. Now
>=3B >=3B cr= eated plpythonu language in my database and created a simple
>=3B >= =3B function to calculate sum of two variables.
>=3B >=3B while impo= rting math libbrary and executing the function i got the error
>=3B &g= t=3B PL/Python: ImportError: No module named cmath
>=3B >=3B
>= =3B >=3B tried to search help for this error on net and tried various thi= ngs
>=3B >=3B but nothing solved this.
>=3B >=3B What can I d= o to solve this error.
>=3B >=3B I can still work from python interp= reter directly.
>=3B >=3B Thanks in advcance.
>=3B >=3B C P K= ulkarni
>=3B This can happen if you have more then one version of pyth= on on the
>=3B server and the postgresql is using a different one the= n you do on the
>=3B command line. This is becuase modules are instal= led per version of python.
>=3B The easiest way to check this is:
&= gt=3B
>=3B create or replace function pyver() returns text as
>= =3B $$
>=3B import sys
>=3B return sys.version
>=3B $$ langu= age 'plpythonu'=3B
>=3B
>=3B select pyver()
>=3B and see if= the version it returns is the same one as when you open the
>=3B int= erpreter.
>=3B
>=3B Sim
>=3B
>=3B --
>=3B Sent = via pgsql-general mailing list (pgsql-general@postgresql.org)
>=3B To = make changes to your subscription:
>=3B http://www.postgresql.org/mail= pref/pgsql-general
= --_96d13dca-c295-4859-981e-0b72a60ec170_--