【问题标题】:How to install psycopg2-2.6 with python2.6如何使用 python2.6 安装 psycopg2-2.6
【发布时间】:2015-08-14 01:30:13
【问题描述】:

我的 linux 服务器:2.6.18 RHEL5

gcc 版本:gcc (GCC) 4.1.2 20080704 (Red Hat 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 install”时,错误信息是:

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”时,结果还是一样。

【问题讨论】:

    标签: python postgresql gcc psycopg2


    【解决方案1】:

    我知道很久以前有人问过这个问题,但我最近遇到了所描述的相同问题(尽管是在 CentOS 系统而不是 Red Hat 上)。

    我不确定这是否会有所帮助,但我的问题是 libpq 的版本(与 Postgres 一起安装)“太旧”。对我有用的解决方案是安装 2.5 版的 psycopg2。这个版本已经足够满足我的需要了。

    我在这里找到了这个想法: https://github.com/psycopg/psycopg2/issues/305

    我使用的是 2.5 版,但也许稍新的版本也可以。我在这里找到了源代码: http://initd.org/psycopg/tarballs/PSYCOPG-2-5/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-12
      • 1970-01-01
      • 2017-04-11
      • 2011-02-02
      • 2018-06-07
      相关资源
      最近更新 更多