python-2.7 - pip install psycopg2==2.6 给出错误命令 "python setup.py egg_info"failed with error code 1 in/tmp/pip-build-f6rRmm/psycopg2/

标签 python-2.7 installation pip psycopg2 postgresql-9.1

我的项目正在运行 postgreSQL,在我将系统升级到 ubuntu 16.04 并再次克隆项目后,我无法安装特定的包。

我也尝试清除 postgresql 和 psycopg2,但无法安装它

(temp) hellrazor@hellrazor-desktop:~/workspace/te___ave/backend/te___ave$ pip install psycopg2==2.6 > ERROR.txt
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-f6rRmm/psycopg2/
(temp) hellrazor@hellrazor-desktop:~/workspace/te___ave/backend/te___ave$ 

这是我得到的错误
Collecting psycopg2==2.6
  Using cached psycopg2-2.6.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    Error: pg_config executable not found.

    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    ----------------------------------------

我做了https://help.ubuntu.com/community/PostgreSQL#Client_Installation中写的所有步骤

同样在 pg_config executable not found 中的一些答案中我看到我需要添加sudo apt-get install libpq-dev python-dev
但它给出了这个输出
(temp) hellrazor@hellrazor-desktop:~/workspace/teamwave/backend/teamwave$ sudo apt-get install libpq-dev python-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-dev is already the newest version (2.7.11-1).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libpq-dev : Depends: libpq5 (= 9.5.10-0ubuntu0.16.04) but 10.1-1.pgdg16.04+1 is to be installed
E: Unable to correct problems, you have held broken packages.

我试图找到如何解决错误,但现在没有得到任何线索。

最佳答案

我认为您遇到了版本锁定的问题 psycopg2 .您已锁定版本 2.6 ,其中有一些已知的构建问题,这些问题在以后的版本中得到解决。

如果您阅读发行说明,请在此处找到:http://initd.org/psycopg/docs/news.html#what-s-new-in-psycopg-2-7-4你会看到版本 2.72.7.4两者都修复了与构建和安装包有关的错误。

我的猜测是您之前安装的 Linux 运行的是旧版本的 Postgres(我认为是 9.5)。但是,现在您升级了操作系统,却在不经意间升级到版本 10 .

这里有四种不同的解决方案可供尝试,但首先您可能需要

  • 确保您的 PostgreSQL 安装配置正确,以便 pg_config可以从你的终端运行。
  • 使用 pip install psycopg2 删除 pip 安装中的版本锁定
  • 版本锁定您的 libpq-dev打包到适合 PostgreSQL 的版本 9.5
  • 重新安装 PostgreSQL 到版本 9.5如果您不需要版本 10
  • 关于python-2.7 - pip install psycopg2==2.6 给出错误命令 "python setup.py egg_info"failed with error code 1 in/tmp/pip-build-f6rRmm/psycopg2/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48594406/

    相关文章:

    python-2.7 - 从数据存储中提取数据并将其转换为Python中的Json(Google Appengine)

    python-2.7 - 如何识别 Python pandas Dataframe 中第一次出现的重复行

    mysql - 如何将密码从 bash 脚本传递给 aptitude 以安装 mysql?

    python - 在构建需要编译代码的模块时将自定义 CMake 标志传递给 pip

    python - Tensorflow(仅 CPU)安装错误 | Ubuntu 14.10 | NumPy 1.8.2

    django - 如何在 Django 中返回 HTTP 400 响应?

    r - 安装旧版本的 R 包

    c# - 如何在不破坏应用程序引用的情况下从部署项目中重新定位程序集?

    python - 没有名为 "Torch"的模块

    python - 如何在虚拟环境中使用 pip