Sunday, 24 April 2016

ImportError _psycopg.so: undefined symbol: lo_truncate64




If you are getting above error in psycopg2 , then for sure on loading an older libpq library is used than the one with which the psycopg2 was installed.

To identify which libpq is the psycopg.so is using issue below command, the output of command should point to right libpq.so file which is latest

ldd /path/to/venv/lib/python2.6/site-packages/psycopg2/_psycopg.so | grep libpq
libpq.so.5 => /usr/pgsql-9.4/lib/libpq.so.5 (0x00007f0d6c027000)

if above output is the correct .so file and you are still getting above error then, try to locate libpq.so in default libraries like /usr/lib64 (on centOS), For me it was below under /usr/lib64
 
lrwxrwxrwx.  1 root root       12 Mar 31 10:15 libpq.so.5 -> libpq.so.5.2
-rwxr-xr-x.  1 root root   162760 Feb 25  2014 libpq.so.5.2

As you can see the _psycopg.so for some reason is trying to load above libpq.so.5 which is an older one. So I removed this softlink file libpq.so.5 and created a new one which points to /usr/pgsql-9.4/lib/libpq.so.5 in /usr/lib64, by
issuing below commands
 
cd /usr/lib64
rm libpq.so.5
ln -s /usr/pgsql-9.4/lib/libpq.so.5 libpq.so.5

Above should fix the issue.

No comments:

Post a Comment