tairyao
tairyao

Reputation: 145

How to install psycopg2-2.6 with python2.6

my linux server: 2.6.18 RHEL5

gcc version: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)

installed rpm packages:

python26-2.6.5-4.el5
python26-devel-2.6.5-4.el5
postgresql-devel-8.1.23-1
postgresql-libs-8.1.23-1
postgresql-devel-8.1.23-1
postgresql-8.1.23-1

when I run "python2.6 setup.py install", the error message is:

gcc -pthread -shared build/temp.linux-x86_64-2.6/psycopg/psycopgmodule.o build/temp.linux-x86_64-2.6/psycopg/green.o build/temp.linux-x86_64-2.6/psycopg/pqpath.o build/temp.linux-x86_64-2.6/psycopg/utils.o build/temp.linux-x86_64-2.6/psycopg/bytes_format.o build/temp.linux-x86_64-2.6/psycopg/connection_int.o build/temp.linux-x86_64-2.6/psycopg/connection_type.o build/temp.linux-x86_64-2.6/psycopg/cursor_int.o build/temp.linux-x86_64-2.6/psycopg/cursor_type.o build/temp.linux-x86_64-2.6/psycopg/diagnostics_type.o build/temp.linux-x86_64-2.6/psycopg/error_type.o build/temp.linux-x86_64-2.6/psycopg/lobject_int.o build/temp.linux-x86_64-2.6/psycopg/lobject_type.o build/temp.linux-x86_64-2.6/psycopg/notify_type.o build/temp.linux-x86_64-2.6/psycopg/xid_type.o build/temp.linux-x86_64-2.6/psycopg/adapter_asis.o build/temp.linux-x86_64-2.6/psycopg/adapter_binary.o build/temp.linux-x86_64-2.6/psycopg/adapter_datetime.o build/temp.linux-x86_64-2.6/psycopg/adapter_list.o build/temp.linux-x86_64-2.6/psycopg/adapter_pboolean.o build/temp.linux-x86_64-2.6/psycopg/adapter_pdecimal.o build/temp.linux-x86_64-2.6/psycopg/adapter_pint.o build/temp.linux-x86_64-2.6/psycopg/adapter_pfloat.o build/temp.linux-x86_64-2.6/psycopg/adapter_qstring.o build/temp.linux-x86_64-2.6/psycopg/microprotocols.o build/temp.linux-x86_64-2.6/psycopg/microprotocols_proto.o build/temp.linux-x86_64-2.6/psycopg/typecast.o -L. -L/usr/lib64 -lpython2.6 -lpq -o build/lib.linux-x86_64-2.6/psycopg2/_psycopg.so
/usr/bin/ld: build/temp.linux-x86_64-2.6/psycopg/psycopgmodule.o: relocation R_X86_64_PC32 against `lobjectType' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld return 1
error: command 'gcc' failed with exit status 1

when I use "gcc -fPIC", the result is still the same.

Upvotes: 2

Views: 543

Answers (1)

Neither_8
Neither_8

Reputation: 111

I know this was asked a long time ago, but I recently came across the same problem described (though on a CentOS system instead of Red Hat).

I am not sure if this will help, but my problem is the version of libpq (installed with Postgres) is "too old". The solution that worked for me was to install version 2.5 of psycopg2. This version is good enough for my needs.

I found the idea here: https://github.com/psycopg/psycopg2/issues/305

I used version 2.5, but perhaps a slightly newer version would work as well. I found the source code here: http://initd.org/psycopg/tarballs/PSYCOPG-2-5/

Upvotes: 1

Related Questions