psycopg2-ctypes
psycopg2-ctypes copied to clipboard
can't import psycopg2 on windows
The setup.py takes a few modifications to get working. However, once installed you can't import psycopg2. You end up with the following error:
I forked the project and made the appropriate edits to setup.py to find libpq.dll. If you like, I can push this small change.
This traceback is from pypy (which is what i want to get working)
>>>> import psycopg2
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\pypy-1.8\site-packages\psycopg2.py", line 7, in <module>
from psycopg2ct import compat
File "C:\pypy-1.8\site-packages\psycopg2ct-2.4.4._ctypes_-py2.7.egg\psycopg2ct
\__init__.py", line 4, in <module>
from psycopg2ct import extensions
File "C:\pypy-1.8\site-packages\psycopg2ct-2.4.4._ctypes_-py2.7.egg\psycopg2ct
\extensions.py", line 15, in <module>
from psycopg2ct._impl import connection as _connection
File "C:\pypy-1.8\site-packages\psycopg2ct-2.4.4._ctypes_-py2.7.egg\psycopg2ct
\_impl\connection.py", line 8, in <module>
from psycopg2ct._impl import libpq
File "C:\pypy-1.8\site-packages\psycopg2ct-2.4.4._ctypes_-py2.7.egg\psycopg2ct
\_impl\libpq.py", line 9, in <module>
libpq = cdll.LoadLibrary(PG_LIBRARY)
File "C:\pypy-1.8\lib-python\modified-2.7\ctypes\__init__.py", line 433, in Lo
adLibrary
return self._dlltype(name)
File "C:\pypy-1.8\lib-python\modified-2.7\ctypes\__init__.py", line 354, in __
init__
self._handle = _ffi.CDLL(name, mode)
OSError: C:/Program Files (x86)/PostgreSQL/9.1/lib/libpq.dll: The specified modu
le could not be found.
>>>>
You also end up with a popup that says: "Python.exe - System Error"
The Program can't start because libintl-8.dll is missing from your computer. Try reinstalling the program to fix this problem."
I have the odbc driver's installed and this dll is located at: C:\Program Files (x86)\PostgreSQL\psqlODBC\0900\bin
The error also shows up in standard python27:
>>> import psycopg2ct
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win32\egg\psycopg2ct\__init__.py", line 4, in <module>
File "build\bdist.win32\egg\psycopg2ct\extensions.py", line 15, in <module>
File "build\bdist.win32\egg\psycopg2ct\_impl\connection.py", line 8, in <modul
e>
File "build\bdist.win32\egg\psycopg2ct\_impl\libpq.py", line 9, in <module>
File "c:\python27\lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "c:\python27\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
>>>
(updated: formatting)
http://blog.kimiensoftware.com/2011/07/windows-postgresql-and-the-case-of-the-vanishing-libint-dll-372