2015-05-31 54 views
2

我的Linux服務器:2.6.18 RHEL5如何安裝psycopg2-2.6與python2.6的

gcc版本:GCC(海灣合作委員會)4.1.2 20080704(紅帽4.1.2-51)

安裝rpm包:

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 

當我運行 「python2.6的安裝的setup.py」,該錯誤信息是:

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 
當我使用

「GCC -fPIC「,結果仍然相同。

回答

1

我知道這是問了很久以前,但我最近遇到描述了同樣的問題來了(雖然CentOS系統,而不是紅帽上)。

我不知道這是否會幫助,但我的問題是libpq的版本(與Postgres的安裝)是「太舊」。爲我工作的解決方案是安裝psycopg2的2.5版本。這個版本足夠滿足我的需求。

我發現這個想法在這裏: https://github.com/psycopg/psycopg2/issues/305

我使用的版本2.5,但也許稍微新版本將正常工作。我發現的源代碼在這裏: http://initd.org/psycopg/tarballs/PSYCOPG-2-5/