【问题标题】:Issues installing psycopg2 in EC2 instance在 EC2 实例中安装 psycopg2 的问题
【发布时间】:2016-06-29 00:42:10
【问题描述】:

我一直在尝试安装包hgvs,它需要 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

通过安装最新版本(2.7.4 和 9.5.3)的 python-dev 和 libpq-dev 解决了类似的错误。 我不知道这会产生多大的影响,但是在运行 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).

不幸的是,我发现的类似问题得到了神奇的单行回答,解决了一些问题。这些都没有奏效,更不用说解释问题的根本原因了。如果有人可以提供帮助,将不胜感激。

【问题讨论】:

    标签: ubuntu amazon-web-services psycopg2


    【解决方案1】:

    使用以下命令就可以了

    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 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package python3.4-dev E: Couldn't find any package by glob 'python3.4-dev' E: Couldn't find any package by regex 'python3.4-dev' 虽然当前安装了 python 3.3。其他命令返回我的包都是最新的,尽管给我的警告与我原来的问题(第二个代码块)中的警告相似。
    • 把这个“python3.4-dev”改成“python3-dev”
    • python3 is already the newest version (3.3.1-0ubuntu1). 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 (&lt; 0.9.9~) but 0.9.7.7ubuntu6 is to be installed libc-bin : Depends: libc6 (&lt; 2.18) but 2.21-7 is to be installed 我应该尝试卸载并重新安装使用'apt-get -f install' 会产生问题的依赖项吗?
    • 是的,我猜是这些依赖导致了这个问题。
    • 我可能需要为此创建一个新问题,但鉴于此消息,我应该多小心地运行命令:WARNING: The following essential packages will be removed. This should NOT be done unless you know exactly what you are doing! apt libapt-pkg5.0 (due to apt) libstdc++6 (due to apt) libc-bin 8 upgraded, 2 newly installed, 256 to remove and 0 not upgraded. 1 not fuly instaled or rmvd. Need to get 3574kB of archives. After this operation, 1565MB disk space will be free. You are about to do something potentialy harmful. To continue type in the phrase 'Yes, do as I say!'
    猜你喜欢
    • 2020-09-16
    • 1970-01-01
    • 2014-03-24
    • 2016-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-22
    • 1970-01-01
    相关资源
    最近更新 更多