1

I have installed postgresql 9.5 on windows 10, x64.

I have created the extension plpython3u with python 3.3.5 on the server's path and it appeared to create the extension successfully:

SELECT * FROM pg_available_extensions
WHERE name like '%python%' order by name;


       name        | default_version | installed_version |                  comment

-------------------+-----------------+-------------------+------------------------------------------
-
 hstore_plpython2u | 1.0             |                   | transform between hstore and plpython2u
 hstore_plpython3u | 1.0             |                   | transform between hstore and plpython3u
 hstore_plpythonu  | 1.0             |                   | transform between hstore and plpythonu
 ltree_plpython2u  | 1.0             |                   | transform between ltree and plpython2u
 ltree_plpython3u  | 1.0             |                   | transform between ltree and plpython3u
 ltree_plpythonu   | 1.0             |                   | transform between ltree and plpythonu
 plpython2u        | 1.0             |                   | PL/Python2U untrusted procedural language
 plpython3u        | 1.0             | 1.0               | PL/Python3U untrusted procedural language
 plpythonu         | 1.0             |                   | PL/PythonU untrusted procedural language
(9 rows)

However when I attempt to create the following function (from the pg docs)

CREATE FUNCTION pymax (a integer, b integer)
  RETURNS integer
AS $$
  if a > b:
    return a
  return b
$$ LANGUAGE plpython3u;

the psql (or pgadmin3) terminal's connection is reset.

The python 3.3 on the path is anaconda's distb and runs fine on its own. I couldn't find the required version of python in the postgresql docs and used dependency walker as described here Postgres database crash when installing plpython to find the required dll that plpython3.dll in the server's lib/ points to.

Can anyone help me with what I have missed?

Many thanks

Community
  • 1
  • 1
pjc42
  • 233
  • 4
  • 9

1 Answers1

0

Looking more carefully at the installation download, I read the readme.txt. This clearly lays out how to include the language packs including plpython. No need to muck around with dependency walker or anything like that.

Following the clear and simple instructions in the readme.txt is all it took to get the plpython extension working fine. No excuse for not reading the readme. My bad.

I was not matching the required version of python. The bottom line is that postgresql does seem to be relatively sensitive to the particular distribution of python, not just version - (I had matched the versions postgres python distb 3.3.4 and anaconda 3.3.4.)

Specifically, setting the server's path to use the python installed along with the server, C:\EnterpriseDB\LanguagePack\9.5\x64\Python-3.3 in my case, was all that it took to get it working correctly.

Thanks go to Adrian Klaver on the pgsql-general mailing list for getting me sorted. This answer is just for future reference as I claim it is easy to miss the readme :-).

pjc42
  • 233
  • 4
  • 9