Monday, 2 December 2013

undefined symbol: PQescapeLiteral error on running python postgresql import


I got an error as follows, on running import pg command on python command line.

import pg

Traceback (most recent call last):

File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/", line 31, in <module>

from _pg import *

ImportError?: /usr/local/lib/python2.7/dist-packages/ undefined symbol: PQescapeLiteral

This seems to be some issue with libpq module for postgresql

Below is the steps that I followed to  fix it.

1)I just checked which is the library directory for postgresql

 pg_config --libdir


2)Then I checked module  which is needed for the postgresql commands to work with python is present on the /usr/lib directory.

  ldd /usr/local/lib/python2.7/dist-packages/ | grep libpq => /usr/lib/ (0x00007f0d6b943000)

3)I can see the is already on the path /usr/lib.  The issue is that the header module for libpq was not installed for the command to run. So I installed it using the command below.

apt-get install libpq-dev

which fixed the issue and now I am able to run the pg command from python command line.


No comments:

Post a Comment