PostgreSQL unable to create plpythonu extension
Asked Answered
N

2

8

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...

Ninnyhammer answered 4/2, 2016 at 20:28 Comment(1)
i am having the same problem i tried it on 9.3,9.5,9.6 , install pyton27 added it to path . nothing on web helped till now . please helpGluck
S
6

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.

Saxe answered 22/8, 2017 at 18:4 Comment(0)
F
2

A full answer can be found: https://postgresrocks.enterprisedb.com/t5/PostgreSQL/unable-to-install-pl-python-extension/m-p/4090 It assumes you have used stackbuilder to install the edb language pack. Do check the commands for correctness in your installation. E.g. path to postgresql data, install path of edb and python version. When you use depency walker (depends.exe), only pay attention to the pythonxx.dll. With older PG versions, this may or may not agree to the version installed by the EDB languages package. For version 10.7, version 3.4 Python is required. For windows, the later 3.4 Python versions do not appear to have a msi installer. You may have to install 3.4.4, or try to upgrade PG 10 to the latest version (10.11) first. This version requires python 3.7, so then you can use the EDB download. But the python version may already exist and be found. could not load library plpython3.dll (here on stackoverflow) was somewhat close, but did not detail the environment vars needed. the solution proposed does not require you to change env vars permanently, which is a great help when using several python installations.

Ferule answered 17/12, 2019 at 16:3 Comment(2)
Your advice worked finally. Postgres10.12 with EDB has worked with pl/python3u.Ian
for anybody trying to work with Postgres and Python this is the best combination: Postgres10.12 + Python3.7. Works like a charm.Ian

© 2022 - 2024 — McMap. All rights reserved.