Ubuntu 在EC2实例中安装psycopg2时出现问题

Ubuntu 在EC2实例中安装psycopg2时出现问题,ubuntu,amazon-web-services,psycopg2,Ubuntu,Amazon Web Services,Psycopg2,我一直在尝试安装这个软件包,它需要psycopg2才能正常工作。使用pip的安装运行平稳,直到出现以下错误: /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libpq.a(fe-connect.o): unrecognized relocation (0x2a) in section `.text' /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit sta

我一直在尝试安装这个软件包,它需要psycopg2才能正常工作。使用pip的安装运行平稳,直到出现以下错误:

/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libpq.a(fe-connect.o): unrecognized relocation (0x2a) in section `.text'

/usr/bin/ld: final link failed: Bad value

collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-ubuntu/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rh6BEQ-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-ubuntu/psycopg2
通过安装python dev和libpq dev解决了类似的错误,这两个版本已经在其最新版本(2.7.4和9.5.3)中。 我不知道这会产生多大影响,但在运行sudo apt get install libpq dev时,我得到:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libpq-dev is already the newest version (9.5.3-1).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 apt-utils : Depends: libdb5.3 but it is not installable
 libapt-pkg5.0 : Breaks: libapt-inst1.5 (< 0.9.9~) but 0.9.7.7ubuntu6 is to be installed
 libc-bin : Depends: libc6 (< 2.18) but 2.21-7 is to be installed
 libc-dev-bin : Depends: libc6 (< 2.18) but 2.21-7 is to be installed
 libc6 : Breaks: libtirpc1 (< 0.2.3) but 0.2.2-5build1 is to be installed
         Breaks: locales (< 2.21) but 2.13+git20120306-9 is to be installed
 libc6-dev : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.21-7 is to be installed
 libpq-dev : Depends: libpq5 (= 9.5.3-1) but it is not installable
 libstdc++6 : Depends: gcc-5-base (= 5.3.1-7) but it is not installable
          Breaks: python-scipy (<= 0.14.1-1) but 0.11.0+dfsg1-1ubuntu2 is to be installed
          Breaks: python3-scipy (<= 0.14.1-1) but 0.11.0+dfsg1-1ubuntu2 is to be installed
 E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
正在阅读软件包列表。。。多恩
构建依赖树
正在读取状态信息。。。多恩
libpq-dev已经是最新版本(9.5.3-1)。
您可能希望运行“apt get-f install”来更正这些问题:
以下包具有未满足的依赖项:
apt-utils:dependens:libdb5.3,但它不可安装
libapt-pkg5.0:中断:libapt-inst1.5(<0.9.9~),但要安装0.9.7.7ubuntu6
libc-bin:取决于:libc6(<2.18),但要安装2.21-7
libc dev bin:dependens:libc6(<2.18),但要安装2.21-7
libc6:Breaks:libtirpc1(<0.2.3),但要安装0.2.2-5build1
中断:区域设置(<2.21),但要安装2.13+git20120306-9
libc6开发:依赖于:libc6(=2.17-0ubuntu5.1),但将安装2.21-7
libpq开发:依赖于:libpq5(=9.5.3-1),但它不可安装
libstdc++6:依赖于:gcc-5-base(=5.3.1-7),但它不可安装

Breaks:pythonscipy(使用以下命令,它将起作用

sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y python3.4-dev
sudo apt-get install -y libpq-dev

pip3 install psycopg2

使用以下命令,它将工作

sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y python3.4-dev
sudo apt-get install -y libpq-dev

pip3 install psycopg2

sudo apt get install-y python3.4-dev读取软件包列表…完成构建依赖关系树读取状态信息…完成E:无法定位软件包python3.4-dev E:无法通过glob'python3.4-dev'找到任何软件包E:无法通过regex'python3.4-dev'找到任何软件包
,尽管当前已安装python3.3。其他r命令返回我的包都是最新的,尽管它给我的警告与我的原始问题(第二个代码块)上的警告类似。将此“python3.4-dev”更改为“python3-dev”
python3已经是最新版本(3.3.1-0ubuntu1)。您可能希望运行“apt get-f install”来更正这些问题:以下软件包具有未满足的依赖项:apt utils:Depends:libdb5.3但它不可安装libapt-pkg5.0:Breaks:libapt-inst1.5(<0.9.9~),但要安装0.9.7.7ubuntu6 libc bin:Depends:libc6(<2.18)但是将要安装2.21-7
我是否应该尝试卸载并重新安装使用
'apt-get-f install'
产生问题的依赖项?是的,我猜这些依赖项导致了这些问题。我可能需要为此创建一个新问题,但鉴于以下消息:
WARN,我应该如何小心地运行该命令ING:将删除以下基本软件包。除非您确切知道自己在做什么,否则不应执行此操作!apt libapt-pkg5.0(由于apt)libstdc++6(由于apt)libc bin 8已升级,2个新安装,256要删除,0未升级。1未完全安装或rmvd。需要获取3574kB的存档。此操作后,1565MB的磁盘空间将被释放。您将要做一些可能有害的事情。若要继续,请键入短语“是,照我说的做!”
sudo apt get install-y python3.4-dev Reading包列表…已完成构建依赖关系树读取状态信息…已完成E:无法定位包python3.4-dev E:无法通过glob'python3.4-dev'找到任何包E:无法通过正则表达式'python3.4-dev'找到任何包
,尽管当前已安装python 3.3。其他命令返回我的包都已升级到date,尽管给出了与我原始问题类似的警告(第二个代码块)。将此“python3.4-dev”更改为“python3-dev”
python3已经是最新版本(3.3.1-0ubuntu1)。您可能希望运行“apt get-f install”来更正这些问题:以下软件包具有未满足的依赖项:apt utils:Depends:libdb5.3但它不可安装libapt-pkg5.0:Breaks:libapt-inst1.5(<0.9.9~),但要安装0.9.7.7ubuntu6 libc bin:Depends:libc6(<2.18)但是将要安装2.21-7
我是否应该尝试卸载并重新安装使用
'apt-get-f install'
产生问题的依赖项?是的,我猜这些依赖项导致了这些问题。我可能需要为此创建一个新问题,但鉴于以下消息:
WARN,我应该如何小心地运行该命令ING:将删除以下基本软件包。除非您确切知道自己在做什么,否则不应执行此操作!apt libapt-pkg5.0(由于apt)libstdc++6(由于apt)libc bin 8已升级,2个新安装,256要删除,0未升级。1未完全安装或rmvd。需要获取3574kB的存档。此操作后,1565MB的磁盘空间将可用。您将要做一些可能有害的事情。若要继续,请键入短语“是,照我说的做!”