ver.2 PyGreSQL ERROR: from _pg import * ImportError: DLL load failed: The specified module could not be found

前端 未结 3 1609
一整个雨季
一整个雨季 2020-12-19 17:17

I have the same problem that was discussed here, but I haven\'t credit to comment an answer so I start new question.

I have in PATH way to libpq.dll (C:\\PostgreSql

3条回答
  •  北海茫月
    2020-12-19 18:04

    I got the same error on Win10 with Python 3.5 and Python 3.8, both are 64bit, and Postresql 12, also 64bit. DLL locations "c:\Program Files\PostgreSQL\12\bin" and "c:\Program Files\PostgreSQL\psqlODBC\bin" were added to the PATH but it caused another error:

    • "from _pg import * ImportError: DLL load failed: The operating system cannot run %1."

    Then I've checked what is going on with Process Monitor from Sysinternals and found that libpg.dll was looking for other DLLs. Finally, the following files:

    • libpq.dll
    • libssl-1_1-x64.dll
    • libcrypto-1_1-x64.dll

    were copied from "c:\Program Files\PostgreSQL\12\bin" folder to:

    • "c:\Users...\AppData\Local\Programs\Python\Python35"
    • "c:\Users...\AppData\Local\Programs\Python\Python38"

    folders and now "import pg" works fine in both versions of Python.

提交回复
热议问题