Search code examples
pythonpostgresqlplpython

PostgreSQL unable to create plpythonu extension


I'm trying to write a function in PostgreSQL on Windows with a Python script in the body and i'm running into an error message when trying to create the plpythonu extension. The command I'm running is:

CREATE EXTENSION plpythonu;

Which produces the following error message:

ERROR: could not access file "$libdir/plpython2": No such file or directory
SQL state: 58P01

I also tried running:

CREATE EXTENSION plpython3u;

which results in this error:

ERROR: could not load library "C:/Program Files (x86)/PostgreSQL/9.2/lib/plpython3.dll": The specified module could not be found.
SQL state: 58P01

The plpython3.dll file exists at this location, but apparently is missing some critical dependency. I've searched everywhere and found nothing helpful on this. I have both Python 2 and 3 installed on the machine...


Solution

  • The newest (9.4 or later) binary installations from EnterpriseDB contain only plpython3u.dll. In versions 9.4 to 9.6 I had to install python 3.3 to get plpython3u run.

    You can check which version of Python is needed by plpython3u.dll using Dependency Walker.