2015-05-31 55 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/