[pyar] psycopg2: ImportError con pg 9.1 y python2.7

Alan Etkin spametki en gmail.com
Sab Jul 28 15:28:50 ART 2012


Resuelto, me pasaron vairos consejos en la lista psycopg2:
> I know It can be related to the issue posted in the FAQ
>
http://initd.org/psycopg/docs/faq.html#problems-compiling-and-deploying-psycopg2
>
> "...You can avoid the problem by using the same version of the pg_config
at
> install time and the libpq at runtime. ..."

Yep, that's the case.

> But I cannot find the command/configuration needed to control the
pg_config
> used at runtime, so I can set the pg_config to the newest version both for
> installation and runtime.

You cannot choose explicitly the lib to use at runtime: you should
manipulate the LD_LIBRARY_PATH to include the newest dir... which is a
pain in the neck. You better compile using the older pg_config.

> Note: I have configured setup.cfg so it reads the updated pg_config file
(pg
> 9.1) before installation.

Yes, this is the problem. You compile with library and headers
offering lo_truncate but don't make it available at runtime.

> This is what ldd returns
>
> [root en pycom ~] #  ldd
> /opt/python2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so | grep
libpq
>         libpq.so.4 => /usr/lib/libpq.so.4 (0x00716000)
>

Yes, this is the 8.1 version.

> There is an older pg_config version stored in /usr/bin with this output:
> LIBDIR = /usr/lib
> VERSION = PostgreSQL 8.1.23

> The new pg_config output:
> LIBDIR = /usr/pgsql-9.1/lib
> VERSION = PostgreSQL 9.1.4

You would live a much healthier life if you could get rid of Postgres
8.1, which is unsupported by the way, and install 9.1 in a standard
location, such as /usr/local/

If you cannot do this, either you compile psycopg against PG 8.1 by
using the pg_config in /usr/bin, or you compile for PG 9.1 but set the
LD_LIBRARY_PATH everywhere you need psycopg2 (you may also try hacking
psycopg's __init__.py file setting os.environ['LD_LIBRARY_PATH'] =
'/usr/pgsql-9.1/lib' before the first "from _psycopg import...")

Note that installing 9.1 in /usr/local could be enough to have the
newer libpq found automatically instead of the older, but I'm not
sure. You can try creating a symlink to the newer libpq.so into
/usr/local/lib and use ldd to check it gets used. This would have a
global effect though: can't guarantee there will be no side effects
from the libraries mixup.


Tuve que reinstalar postgresql en la ruta estándar porque el rpm que usé
anteriormente tenía alguna incompatibilidad al compilar psycopg2, incluso
cuando le pasaba la ubicación del nuevo pg_config (no encontré cuál era el
problema).
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20120728/901d2a52/attachment.html>


More information about the pyar mailing list