Install plpython3u
If you're lucky, the following command will just work, and the Python language has been successfully installed:
If you encounter the following error:
We have a little more work to do.
PostgreSQL 9.1 requires a VERY specific sub-version of the Python DLL: Python 3.2.x. (available here) Any other version (3.1.x, 3.3.x, or otherwise) will cause the installation of plpython3u to fail. In addition, PostgreSQL 9.1 unfortunately does not appear to ship with Python 2.x support either.
If Python 3.2.x is not installed, download and install it.
Browse to your Python 3.2.x installation directory. By default, this should be something similar to: C:\Python32. From here, navigate to the DDLs directory and locate a DLL named python3.dll.
In a separate window, browse to you PostgreSQL installation directory. By default, this should be something similar to: C:\Program Files\PostgreSQL\9.1. From there, navigate into the lib directory and copy the python3.dll from the other window into this directory. Rename the copied DLL from python3.dll topython32.dll.
Finally, attempt to run the CREATE EXTENSION command again:
This time, you should receive the expected result; signalling the installation was successful.
Testing Your plpython3u Extension
First, we need a stored procedure which utilizes the Python language:
Now, let's query our new function:
You should receive a response similar to the following: