Search code examples
pythonpostgresqldllimportpygresql

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


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\lib) but it doesn't solve this problem.

Using Python 2.7.9 32-bit, PostgreSQL 8.4, Win 8

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
    import pg
  File "C:\Python27\lib\site-packages\pg.py", line 21, in <module>
from _pg import *
ImportError: DLL load failed: The specified module could not be found.

Solution

  • I was also facing the same issue on Win 8. First time I had installed PostgreSQL in "C:\Program Files" and also set environment PATH to point to PostgreSQL folder. I was suspecting permission issue for "C:\Program Files" folder.

    I was able to fix this issue by following the steps as mentioned below.

    • Uninstalled PostgreSQL
    • Re-installed PostgreSQL in "C:\PostgreSQL" Note that I have not installed PostgreSQL into "C:\Program Files" folder this time
    • Set the environment PATH C:\PostgreSQL\9.4;C:\PostgreSQL\9.4\bin
    • Also ensure that _pg.pyd exist in C:\Python27\Lib\site-packages