PL/Python

Started by Chris Hallover 23 years ago4 messagesgeneral
Jump to latest
#1Chris Hall
hall.cj@verizon.net

Our machine is running:
Python 2.2 (#1, Feb 24 2002, 16:21:58)
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux-i386

Our Postgres source is from ftp.postgresql.org[64.49.215.8]:21 (via 'wget'):
-rw-r--r-- 1 postgres postgres 9239158 Aug 22 23:25
postgresql-7.2.2.tar.gz

We had to get the Python 2.2.1 source and fiddle with Postgres' makefile
'-I' statement (in the appropriate place, we think) to point to the
Python headers, but everything seemed to build and install OK after that.

We brought up postmaster, added 'plpgsql' to 'template1', no problem.
However, when we try to add 'plpython':

[postgres@linuxbox postgres]$ /usr/local/pgsql/bin/createlang plpython
template1
ERROR: Load of file /usr/local/pgsql/lib/plpython.so failed:
/usr/local/pgsql/lib/plpython.so: undefined symbol: PyExc_IOError
ERROR: Load of file /usr/local/pgsql/lib/plpython.so failed:
/usr/local/pgsql/lib/plpython.so: undefined symbol: PyExc_IOError
createlang: language installation failed

We noticed 'libplpython.so' in 'src/pl/plpython', so we set
'LD_LIBRARY_PATH' - same error. We also added '/usr/lib/'
(libpython2.2.so.0.0 is there) to LD_LIBRARY_PATH - no change.

We *love* Python, and think it will be ideal for a good number of our
stored procedures/functions, and in fact this Postgres installation is
to support a Zope application we are currently developing/using with
Postgres 7.2.

We (obviously) are not terribly skilled at installing Postgres (though
we do usually build from source) - our efforts are directed elsewhere -
could someone help us with what is probably a blindingly obvious problem
to a Postgres expert?

Permissions, perhaps?

--
One OS to rule them all, one OS to find them,
One OS to bring them all and in the database bind them,
In the Land of Redmond, where the Shadows lie.

#2Chris Hall
hall.cj@verizon.net
In reply to: Chris Hall (#1)
Re: Installing PL/Python (progress!)

After some digging in various news groups, we added '-export-dynamic' to
link our link flags, and re-built Python *and* Postgres, and re-installed.

Result: now we get a different error message when we try to 'createlang
plpython':

-----( snip )---------------
bash-2.05$ /usr/local/pgsql/bin/createlang plpython template1
ERROR: Load of file /usr/local/pgsql/lib/plpython.so failed:
/usr/local/lib/python2.2/config/libpython2.2.so: undefined symbol: openpty
createlang: language installation failed
-----( snip )---------------

This constitutes progress, right?

We are doing this as user 'postgres', which is the user postmaster runs as.

If, as user 'postgres', we load python interactively from the command
line, we can import module 'pty', and successfully invoke 'openpty()' -
it returns: (3, 4). BTW, we have verified that plpython.so was created
after libpython2.2.so.

Anybody have any ideas?

Chris Hall wrote:

Our machine is running:
Python 2.2 (#1, Feb 24 2002, 16:21:58)
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux-i386

Our Postgres source is from ftp.postgresql.org[64.49.215.8]:21 (via
'wget'):
-rw-r--r-- 1 postgres postgres 9239158 Aug 22 23:25
postgresql-7.2.2.tar.gz

We had to get the Python 2.2.1 source and fiddle with Postgres' makefile
'-I' statement (in the appropriate place, we think) to point to the
Python headers, but everything seemed to build and install OK after that.

We brought up postmaster, added 'plpgsql' to 'template1', no problem.
However, when we try to add 'plpython':

[postgres@linuxbox postgres]$ /usr/local/pgsql/bin/createlang plpython
template1
ERROR: Load of file /usr/local/pgsql/lib/plpython.so failed:
/usr/local/pgsql/lib/plpython.so: undefined symbol: PyExc_IOError
ERROR: Load of file /usr/local/pgsql/lib/plpython.so failed:
/usr/local/pgsql/lib/plpython.so: undefined symbol: PyExc_IOError
createlang: language installation failed

We noticed 'libplpython.so' in 'src/pl/plpython', so we set
'LD_LIBRARY_PATH' - same error. We also added '/usr/lib/'
(libpython2.2.so.0.0 is there) to LD_LIBRARY_PATH - no change.

We *love* Python, and think it will be ideal for a good number of our
stored procedures/functions, and in fact this Postgres installation is
to support a Zope application we are currently developing/using with
Postgres 7.2.

We (obviously) are not terribly skilled at installing Postgres (though
we do usually build from source) - our efforts are directed elsewhere -
could someone help us with what is probably a blindingly obvious problem
to a Postgres expert?

Permissions, perhaps?

--
One OS to rule them all, one OS to find them,
One OS to bring them all and in the database bind them,
In the Land of Redmond, where the Shadows lie.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Chris Hall (#2)
Re: Installing PL/Python (progress!)

Chris Hall <hall.cj@verizon.net> writes:

bash-2.05$ /usr/local/pgsql/bin/createlang plpython template1
ERROR: Load of file /usr/local/pgsql/lib/plpython.so failed:
/usr/local/lib/python2.2/config/libpython2.2.so: undefined symbol: openpty
createlang: language installation failed

What shared library provides openpty() on your system? Is that library
in the dynamic loader's search path?

It might be useful to do
ldd /usr/local/lib/python2.2/config/libpython2.2.so
and see how the library's shared-library references get resolved.

regards, tom lane

#4Chris Hall
hall.cj@verizon.net
In reply to: Chris Hall (#1)
Re: Installing PL/Python (progress!)

Thanks for the response! We have been involved in production 'issues'
today, sorry I didn't get back on this sooner (plus we are on Hawaiian
time). (3 hours later - the first response bounced at Verizon's outgoing
mail server, for some reason).

'openpty' is a function defined in a Python library module 'pty'. I'm
not sure how the load mechanism would work, I guess it's time for me to
'use the source!'?

BTW,
bash-2.05$ ldd /usr/local/pgsql/lib/plpython.so
libpython2.2.so => /usr/local/lib/libpython2.2.so (0x4000a000)
libc.so.6 => /lib/libc.so.6 (0x400f8000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

and,
bash-2.05$ ldd /usr/local/lib/libpython2.2.so
libc.so.6 => /lib/libc.so.6 (0x400ee000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

Doesn't seem overly helpful in this case, except to maybe eliminate an
avenue of inquiry?

Thanks again, Tom.

Chris Hall

Tom Lane wrote:

Chris Hall <hall.cj@verizon.net> writes:

bash-2.05$ /usr/local/pgsql/bin/createlang plpython template1
ERROR: Load of file /usr/local/pgsql/lib/plpython.so failed:
/usr/local/lib/python2.2/config/libpython2.2.so: undefined symbol: openpty
createlang: language installation failed

What shared library provides openpty() on your system? Is that library
in the dynamic loader's search path?

It might be useful to do
ldd /usr/local/lib/python2.2/config/libpython2.2.so
and see how the library's shared-library references get resolved.

regards, tom lane

--
One OS to rule them all, one OS to find them,
One OS to bring them all and in the database bind them,
In the Land of Redmond, where the Shadows lie.