To get the obvious out of the way, my question is posted after reading many other questions like this one
https://stackoverflow.com/questions/60683776/install-pl-python-on-windows-for-postgresql-12 But I ve been stuck for about a month and half now when trying to use pl/python.I'm using Postgresql 12 with the enterprisedb package including pgadmin4 as a gui and the language pack . So PL python is supposed to be included.When i ran "CREATE EXTENSION plpython3u;"

I got the following message ERROR: ライブラリ"C:/Program Files/PostgreSQL/12/lib/plpython3.dll"をロードできませんでした: The specified module could not be found. SQL state: 58P01which is the classic "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

Also when running plpython3.DLL found in C:\program files\postgresql\12\lib through the software "dependency walker" I get the following result :

enter image description here

Which would mean that -it's indeed python 3.7 which is required as mentioned in the doc. -the dependency was found.

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

and 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. in python interpreter, the syntax is invalid. and when I use the query in pgadmin I have the same error. I saw other possible methods like a batch file or windows settings but it seems completely different.

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

  • hi, did you resolve this issue? Jul 16 '21 at 14:55

Using set at the command prompt does not give feedback upon success. To verify it was actually set, you would run echo %PYTHON_HOME%. But it looks like you have a space after c:\ that should not be there.

Also, this only sets the variables for the particular cmd session you run it in, so it works only if you are starting PostgreSQL from that command prompt. That isn't how you usually run PostgreSQL on Windows, you normally run it as a service. So you have would have to use the GUI interface to "edit the system environment variables", not use set from the command line.

  • Thanks for your answer! I used the "echo %PYTHON_HOME%" line to check whether my setting was effective and it works. the other part of your answer is not entirely clear for me and opens 3 questions for me 1- which GUI are you referring to ? pgadmin4 ? 2- if so how are you supposed to edit the system environment variable from there ? 3- and why is the documentation giving those those command prompt if you do the modification from the GUI/pgadmin (or did I read it wrong ?) ?
    – jiquvox
    Sep 6 '20 at 6:14
  • The GUI is part of Windows. In 10 you just type "environ" at the start menu and it will find it. There is probably a purely text-based way to do it (or maybe 8 of them) but I don't what they are. The doc you linked to is for Advanced Server, which is a different product (EDB's fork of PostgreSQL, not their packaging of the community version) and one I know nothing about. But often docs just aren't very good, so it wouldn't surprise me if that advice is also wrong.
    – jjanes
    Sep 6 '20 at 14:24
  • I edited the environment variable from Windows as suggested : Path, PythonPath, PythonHome.The python 37 dll is found althought it seems it has its own dependent dll ?/subdll which aren't found. It seems to be looking for those dll in the system32 folder. I could post a snapshot in the original post if it helps. Anyway, whether it's related or not, I still have the same classic error "ERROR: could not load library "C:/Program Files/PostgreSQL/12/lib/plpython3.dll": The specified module could not be found.". So Environment variable setting problem ? System 32 problem ? Something else ?
    – jiquvox
    Sep 9 '20 at 13:23
  • 2nd precision : Depedency walker has the following log - "Error: At least one required implicit or forwarded dependency was not found. Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. Error: Modules with different CPU types were found. Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module."
    – jiquvox
    Sep 9 '20 at 13:25
  • 3rd and final comment : Here's the capture of Dependency walker if it's of any help : imgur.com/aGLdnGu
    – jiquvox
    Sep 9 '20 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.