【问题标题】:how install python3.4 psycopg2 in centos pyvenv如何在centos pyvenv中安装python3.4 psycopg2
【发布时间】:2014-05-29 23:40:38
【问题描述】:

我在我的 centos 6.5 中安装了 python 3.4 我按照本教程进行操作

http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/

所以我不更改系统默认python 2.6.6

我使用 python3.4 pyvenv 为我的 django 网站创建一个项目文件夹 现在我需要安装 postgresql 数据库,所以我尝试安装 psycopg2。 在那个 pyvenv 中,python 版本是 3.4

当我 pip install psycopg2 时,它显示错误

Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded
  Running setup.py (path:/mysns/build/psycopg2/setup.py) egg_info for package psycopg2

    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'.
    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'

warning: manifest_maker: standard file '-c' not found



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'.

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /mysns/build/psycopg2
Storing debug log for failure in /root/.pip/pip.log

然后我做了一点搜索,有人说我需要安装其他库 我需要这样做

yum install libpqxx-devel python-devel

一切安装完成 但是,然后我安装 psycopg2, 点安装 psycopg2, 它仍然显示相同的错误 然后我注意到,以前的库,只安装了 python-devel-2.6.6 这是默认的系统 python 版本 即使我尝试

yum python3-devel,

它不会将 python3.4 开发库安装到我的 python3.4 pyvenv 文件夹中

我该如何解决这个问题?我可以在这个 pyvenv 文件夹中安装 python3.4 开发库吗?

【问题讨论】:

  • 错误说找不到pg_config,对吧?安装了 PostgreSQL 吗?如果执行 which pg_config 会得到什么?

标签: python django postgresql python-3.x centos6


【解决方案1】:

我遇到了同样的问题,我环顾四周,发现了以下使它起作用的包:

wget https://forensics.cert.org/cert-forensics-tools-release-el7.rpm
sudo rpm -Uvh cert-forensics-tools-release*rpm
sudo yum --enablerepo=forensics install python3-psycopg2

我还发现有一个名为 python33-python-psycopg2 的包可以帮助你,但我没有尝试过,所以把它当作一个摇摇欲坠的机会而不是一条路,无论如何http://developerblog.redhat.com/2013/06/24/using-rhscl-django-on-python-3-with-postgresql/你可以找到解释。

【讨论】:

    【解决方案2】:
    python3.4 -m pip install psycopg2
    

    【讨论】:

      猜你喜欢
      • 2017-05-27
      • 2012-10-06
      • 2016-01-23
      • 2014-07-23
      • 2016-10-16
      • 2011-06-16
      • 1970-01-01
      • 1970-01-01
      • 2017-06-04
      相关资源
      最近更新 更多