I have tried to install the PL/Python v2.x language inside PostgreSQL on my database running the query:
CREATE EXTENSION plpythonu;
(I got this from http://www.postgresql.org/docs/9.3/static/plpython.html)
But I'm getting this error:
ERRO: não pôde acessar arquivo "$libdir/plpython2": No such file or directory
********** Error **********
ERRO: não pôde acessar arquivo "$libdir/plpython2": No such file or directory
SQL state: 58P01
How to install this in an automated way? I need to install it on many computers.
Typically this error message is a misleading one emitted by the Windows API LoadLibrary
call. What it actually means is closer to:
Error when loading
plpython2.dll
: Cannot find dependency DLLpython27.dll
onPATH
but instead Windows just acts like it is plpython2.dll
its self that could not be loaded.
You can tell if this is the issue by checking the lib
directory of your PostgreSQL install for a plpython2.dll
. If it's there, but you get this error, then it's a missing Python runtime. If there's no plpython2.dll
at all then your PostgreSQL install is missing plpython2, something I'm raising with the packaging team.
If you have plpython2.dll
but it won't load, you need to install the Python runtime that matches the PostgreSQL version. It must be the same Python major version as was used to compile PostgreSQL, e.g. if Python 2.7 was used to compile PostgreSQL, Python 2.6 won't work to run plpython.
It'd be nice if installing the required runtime was automated via the installer, but at present it isn't. It's also not properly documented, which I'll take up with the packaging team The correct runtime to install is now documented in doc\installation-notes.html
inside the install directory, which you can also get to via PostgresSQL 9.3 -> Documentation -> Installation Notes in the Start menu.
For older relases that lack this information in their "installation notes" file, if you're not sure what version of Python is required you can use depends.exe
(dependency walker) to see which Python DLL it's linked to. You need the same architecture of Python too - if you're installing 64-bit PostgreSQL you need 64-bit Python, etc.
The PostgreSQL 9.3 packages require Python 27. So go download Python 2.7 from http://python.org/ (not ActiveState, they aren't necessarily compatible). Make sure Python is added to the PATH
by the installer (it's an option when you run the installer). Then re-try after re-starting PostgreSQL.
You can automate installation of Python with:
start /wait msiexec /i python-2.7.3.amd64.msi /qb /passive TARGETDIR=%SystemDrive%\Python27_x64 ALLUSERS=1
where python-2.7.3.amd64.msi
is the filename of the Python binary you installed, and you're installing the 64-bit version to C:\Python27_x64
. Adjust as desired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With