Re: [modwsgi] ImportError: libpq.so.5 under psyopg2

2,877 views
Skip to first unread message

Graham Dumpleton

unread,
Jul 23, 2012, 9:31:08 AM7/23/12
to mod...@googlegroups.com
On 23 July 2012 00:43, Vivek Tawde <vivek...@gmail.com> wrote:
> Hi,
> I am trying to import pysopg2 module within wsgi script in embedded mode.
> The script throws an exception in the httpd log:
> File "/usr/local/lib/python2.6/site-packages/psycopg2/__init__.py", line 67,
> in <module>
> from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
> ImportError: libpq.so.5: cannot open shared object file: No such file or
> directory
>
> I checked the permissions on the on the postgres library path and it seems
> correct. Any clues about this issue?

Presuming they are actually installed, sounds like your PostgreSQL
libraries are installed in a non standard location.

Were you relying on a LD_LIBRARY_PATH environment variable in your
user environment to find the libraries? This will not be picked up by
Apache.

If your PostgreSQL libraries are installed in a non standard location
and you can't have them installed in a directory on standard system
library search path, then when building the Python client module for
PostgreSQL, set LD_RUN_PATH temporarily to include the directory where
the libraries will be installed. That way the directory will embedded
in the psycopg2 extension module and will automatically know where to
get libraries from at run time without needing LD_LIBRARY_PATH.

So, where is libpq.so installed?

Graham

Vivek Tawde

unread,
Jul 23, 2012, 2:12:38 PM7/23/12
to mod...@googlegroups.com
Thanks for the tip. I will try this.
The current location of libpq.so.5 is /opt/Postgres/9.0/lib/

-vivek

Vivek Tawde

unread,
Jul 24, 2012, 2:04:05 PM7/24/12
to mod...@googlegroups.com
I was able to resolve this issue by installing pysopg2 from source. http://initd.org/psycopg/download/
Before you run the python setup.py install, you will need to edit setup.cfg and set library_dirs=/opt/PostgreSQL/9.0/lib
This worked for me. Thanks again.

-vivek

Graham Dumpleton

unread,
Jul 24, 2012, 2:17:18 PM7/24/12
to mod...@googlegroups.com
Most likely that is triggering setting the equivalent -R option to
compiler, which does same thing as LD_RUN_PATH. That or it could even
be setting LD_RUN_PATH itself.

Graham
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/modwsgi/-/deH3Ph4cLuEJ.
>
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to
> modwsgi+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
Reply all
Reply to author
Forward
0 new messages