OpenBSD, PostgreSQL9.2, python2.7
Trying to import psycopg2 module from python command line:
Python 2.7.3 (default, Aug 3 2012, 05:33:56)
[GCC 4.2.1 20070719 ] on openbsd5
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 67, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: Cannot load specified object
psycopg2 is compiled and installed. I saw _psycopg.so in /site-packages/psycopg2 folder. Maybe he can not see this library ?
The
psycopg2python module includes an extension written in C. That extension cannot be loaded, because another C library that it is depending on is missing.Check that you still have the PostgreSQL client libraries installed, and that
psycopg2can find it.Note that if you run Django in a WSGI server, you need to have set the
LD_LIBRARY_PATHenvironment variable before the WSGI server starts. Alternatively, recompile thepsycopg2extension withLD_RUN_PATH=/usr/local/pgsql/libto ‘hardcode’ the path to the PostgreSQL client library at linking time, removing the need to setLD_LIBRARY_PATH.A last resort would be to add the
/usr/local/pgsql/libpath to/etc/ld.so.conf, see theld.so(8)manpage.