Cannot install plpython for postgres 12

1.2k views Asked by At

First off , my question is posted after reading many other questions like this one Install PL/Python on Windows for PostgreSQL 12 and various trials of previous methods and comments.

But I ve been stuck for about a month and half now when trying to use pl/python.

Configuration

I used the edb postgresql-12.1-3-windows-x64 package including

-PostgreSQL 12.1, compiled by Visual C++ build 1914, 64-bit

-pgadmin4 as a gui

-the language pack .

+Installed separately various version of python on top of the language pack (since it didn't work). Right now I'm on Python 3.7.6 v3.7.6:43364a7ae0, [MSC v.1916 64 bit (AMD64)] on win32

The problem

When i ran "CREATE EXTENSION plpython3u;"

I get what appears to be a classic error message "ERROR: could not load library "C:/Program Files/PostgreSQL/12/lib/plpython3.dll": The specified module could not be found."

My understanding, based on reading multiples posts and articles, is that 2 elements are required

1. the proper python interpreter

Python runtime needs to match the PostgresSQL version The documentation within the PostgreSQL folder indicates

The procedural languages pl/Perl, pl/Python and pl/Tcl are included in this distribution of PostgreSQL. The server has been built using the LanguagePack community distributions of those language interpreters. To use any of the these languages from within PostgreSQL, download and install the appropriate interpreters and ensure they are included in the PATH variable under which the database server will be started. The versions used are shown below - newer minor (bugfix) releases may also work, but have not been tested: Python 3.7

when running plpython3.DLL found in C:\program files\postgresql\12\lib through the software "dependency walker" I had various results depending on the version of python I installed.

-When I used python 3.7.6 () 32 bits it seemed to work to some extent. At least the dependency was found but it was in red with some question mark in other dlls dependent of the python dll :

enter image description here

-as I run PostgreSQL 64 bit, I uninstalled this and I'm running now python 3.7.6 () 64 bits as mentioned at the beginning of the post. Somehow it makes things worse as I have only a question mark now in front of the python37dll and nothing else. Like it's not even found anymore. Why ????

2. setting the environment variables PATH and PYTHONHOME

Now both the documentation https://www.enterprisedb.com/edb-docs/d/edb-postgres-advanced-server/user-guides/language-pack-guide/12/EDB_Postgres_Language_Pack_Guide.1.09.html# and a forum help administrator https://postgresrocks.enterprisedb.com/t5/PostgreSQL/unable-to-install-pl-python-extension/td-p/4059/

mentions the needs to change environment variables PATH and PYTHONHOME. something along the lines of

set PYTHON_HOME=c:\edb\languagepack\v1\Python-3.7


set PATH=C:\edb\languagepack\v1\Python-3.7;C:\edb\languagepack\v1\Perl-5.26\bin;C:\edb\languagepack\v1\Tcl-8.6\bin;%PATH%

the forum mentions you need to change those with the command prompt. the doc isn't specific as to how you re supposed to do that but i figured it meant the python interpreter itself

either way it doesnt work. when I use the command prompt there is no answer: no error, no nothing. It just starts new on another line. I was taught the echo %PYTHON_HOME% command and it seems it is taken into account for the session at least. But I still have the same error. Regarding that, someone mentioned to me that the command prompt approach was wrong anyway because it would require to run postgresql through the command approach then. He told me I needed to run this as a windwow service and I have no idea how to do that.

I really want to move forward after being stuck so long and would much appreciate any insight.

1

There are 1 answers

1
GeoStoneMarten On

Look at this message. Error during: CREATE EXTENSION plpython3u; on PostgreSQL 9.6.0

For PlPython there is 2 solutions:

  • you want use a specific python version > use source and compil it
  • you want use an edb installer > install version of python used when it's compiled the dll need to be placed in c:\windows\system32

Use Stack Builder! and install add-ons EDB Language Pack with your database version

enter image description here

It can be run after installation for exemple enter image description here