Psycopg2 about undefined symbol:lo_truncate64 solutions

Source: Internet
Author: User
Tags postgresql

Today, when installing PSYCOPG2 under centos6.5 and using Python to connect to the PostgreSQL database, there was a undefined symbol:lo_truncate6 error:

Django.core.exceptions.ImproperlyConfigured:Error loading PSYCOPG2 module:/mydev/pyweb/cancerdb/lib/python2.7/ site-packages/psycopg2/_psycopg.so:undefined symbol:lo_truncate64

The reason, as Http://initd.org/psycopg/docs/faq.html describes:

"This means that PSYCOPG is compiled with lo_truncate () support (i.e. the LIBPQ used at compile time WA S version >= 8.3) but at runtime a older LIBPQ dynamic library is found. Fast-forward several years, if the message reports undefined symbol:lo_truncate64 It means that PSYCOPG was Buil T with large objects-bits API support (i.e. the LIBPQ used at compile time is at least 9.3) but at runtime an Older LIBPQ Dynamic library is found. "

(PSYCOPG uses lo_truncate () to compile at least 9.3 or more versions, but at compile time it discovers a lower version of LIBPQ. )

On the internet to see a lot of people by modifying the PSYCOPG2 installation package under the setup.cfg , add PostgreSQL pg_config, and then re-install PSYCOPG2 manually to solve:

£ º£vi  setup.cfg ... # full path.pg_config=/usr/local/psql- 9.4. 0/bin/1fordate/ time representation.use_ Pydatetime=1 .....

Try to find that this method can not solve the problem fundamentally, undefined symbol:lo_truncate6 error still exists.

After some groping, combined with the official documents of PSYCOPG2 , later discovered the need to replace the libpq.so.5 of PostgreSQL with the libpq.so.5 of the system, Re-install the PSYCOPG2, the problem can be resolved:

1. Find what's the LIBPQ dynamic library used at runtime (find LIBPQ dynamics libraries used during the run):

grep LIBPQ   

2. Can avoid the problem by using the same version of the pg_config at install time and the LIBPQ at runtime (for LIBPQ Dynamic Library in the run process):

[Email protected] -: -: $/usr/local/download/psycopg2-2.6.1= cd/usr/Lib64[email protected] -: -: the/usr/lib64=RMLibpq.so.5[email protected] -: -: the/usr/lib64=LN-s/usr/local/postgresql-9.4.0/lib/libpq.so.5./

3, reinstall PSYCOPG2, solve the problem.

[Email protected] -: -: the/mydev/pyweb/download/psycopg2-2.5.4=Pythonpython2.7.5(Default, Jan -  -, -: +: -) [GCC4.4.7 20120313(Red Hat4.4.7- One)] on Linux2type" Help","Copyright","credits"Or"License"  for  Moreinformation.>>>Import PSYCOPG2>>>

Psycopg2 about undefined symbol:lo_truncate64 solutions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.