I'm trying to install plpython in my Postgres 9.1 but it crashes the server:
postgres@dataserver1:~> /opt/postgres/9.1/bin/psql -d mydb
psql.bin (9.1.4)
Type "help" for help.
mydb=# create language 'plpythonu';
The connection to the server was lost. Attempting reset: Failed.
I have python 2.6.8 installed and the handler is correcty declared in the system:
select tmplname, tmplhandler, tmpllibrary from pg_pltemplate where tmplname like 'plpython%'
"plpythonu" | "plpython_call_handler" | "$libdir/plpython2"
"plpython2u" | "plpython2_call_handler" | "$libdir/plpython2"
And the handler is installed in the $libdir:
postgres@dataserver1:~> ll /opt/postgres/9.1/lib/postgresql/plpython*
-rwxr-xr-x 1 root root 6686333 Aug 17 14:27 /opt/postgres/9.1/lib/postgresql/plpython2.so
Any clues on this will be apreciated
EDIT
I've tried create extension plpythonu, plpython2u, and plpython3u and all of them crashes the server.
Reading a little in the docs I found the \dx command to list the installed extensions:
mydb=# \dx
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(1 row)
So I guess the only installed extension is plpgsql.
mydb=# select name, installed_version from pg_available_extensions where name like '%python%';
name | installed_version
------------+-------------------
plpython2u |
plpython3u |
plpythonu |
(3 rows)
and my extension directory:
postgres@dataserver1:/opt/postgres/9.1/share/postgresql/extension> ll *python*
-rw-r--r-- 1 root root 351 Aug 20 17:32 plpython2u--1.0.sql
-rw-r--r-- 1 root root 196 Aug 20 17:32 plpython2u.control
-rw-r--r-- 1 root root 402 Aug 20 17:32 plpython2u--unpackaged--1.0.sql
-rw-r--r-- 1 root root 351 Jun 1 02:54 plpython3u--1.0.sql
-rw-r--r-- 1 root root 196 Jun 1 02:54 plpython3u.control
-rw-r--r-- 1 root root 402 Jun 1 02:54 plpython3u--unpackaged--1.0.sql
-rw-r--r-- 1 root root 347 Aug 20 17:32 plpythonu--1.0.sql
-rw-r--r-- 1 root root 194 Aug 20 17:32 plpythonu.control
-rw-r--r-- 1 root root 393 Aug 20 17:32 plpythonu--unpackaged--1.0.sql
EDIT
I'm running on Linux SuSE, but got your point.
In my postgres instalation, the pl-lang libraries are in .../postgres/9.1/lib/postgres. Inside it there are plpython2.so and plpython3.so
Checking the dynamic linked libraries of these files:
alfonso@dataserver1:/opt/postgres/9.1/lib/postgresql> sudo ldd plpython2.so
linux-vdso.so.1 => (0x00007fff5e945000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f64064df000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f64062da000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f64060d7000)
libm.so.6 => /lib64/libm.so.6 (0x00007f6405e5e000)
libc.so.6 => /lib64/libc.so.6 (0x00007f6405ae9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6406b2e000)
There is no reference to any python library, neither for plpython3.so
But I have installed python 2.6 and python 3.2. Note that I wish to install the extension for python 2.
And yes, CREATE EXTENSION is still crashing:
mydb=# create extension plpython2u;
The connection to the server was lost. Attempting reset: Failed.
!> \q
Postgres 9.0 with Python 2.7 installed on WIN 8.1 64-bit. FYI: Here is how I managed to solve the ERROR: could not load library "C:/Program Files/PostgreSQL/9.0/lib/plpython.dll" when running CREATE LANGUAGE plpythonu; in pgAdmin
Note: As of PostgreSQL 9.1, most procedural languages have been made into "extensions", and should therefore be installed with CREATE EXTENSION not CREATE LANGUAGE. Direct use of CREATE LANGUAGE should now be confined to extension installation scripts. If you have a "bare" language in your database, perhaps as a result of an upgrade, you can convert it to an extension using CREATE EXTENSION langname FROM unpackaged.
To install PL/Python in a particular database:
from the shell command line use createlang plpythonu dbname
Caution
createlang is deprecated and may be removed in a future PostgreSQL release. Direct use of the CREATE EXTENSION command is recommended instead.
http://www.postgresql.org/docs/9.1/static/plpython.html
EDIT
Step by step
Download the postgresql-9.1.5-1-windows.exe and install it.
First let's see what's already there.
Nothing installed !!
Looking at the lib folder and there is only.
....\PostgreSQL\9.1\lib\plpython3.dll.
So I must try to install plpython3u.
There must be something wrong with plpython3.dll.
Looking into plpython3.dll there is a reference to python32.dll.
Back in SQL Shell i typed
I got the message
Looking for the result with:
There it is the installed_version 1.0 of plpython3u
and i also can see it in PgAdmin III
Hope that helps !
EDIT:
Try it manually
Step 1
Step 2
Step 3
Tested with Python 2.6.5