【问题标题】:Psycopg2 on Amazon Elastic BeanstalkAmazon Elastic Beanstalk 上的 Psycopg2
【发布时间】:2013-06-12 19:21:12
【问题描述】:

我正在尝试上传我的项目(在 python 中),该项目将 Psycopg2 用于 Amazon Elastic Beanstalk。我正在使用包含我的项目和 requirements.txt 文件的 zip 文件来执行此操作。

但我收到此错误:

下载/解压 psycopg2>=2.4.6(来自 -r /opt/python/ondeck/app/requirements.txt(第 3 行))运行 setup.py 包 psycopg2 的 egg_info 错误:找不到 pg_config 可执行文件。

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

如何在亚马逊上解决这个问题?

【问题讨论】:

  • 你的 requirements.txt 文件是什么样的?
  • 我的 requirements.txt 是:tornado>=2.0.0 httplib2>=0.8 psycopg2>=2.4.6
  • 如果你运行which pg_config会发生什么?

标签: python amazon-web-services psycopg2 amazon-elastic-beanstalk


【解决方案1】:

您的容器中需要 postgresql-devel。 创建一个包含内容的文件“.ebextensions/packages.config”:

packages:
  yum:
    postgresql94-devel: []

用您需要的任何版本的 postgres 替换 postgresql94-devel 中的 94。例如,postgresql93-devel 用于 postgres 9.3。

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-packages

【讨论】:

  • 我收到错误消息“Yum 没有 postgresql-devel”。
  • 尝试 postgresql94-devel 或您的实例需要的任何版本。 eb ssh 到实例上并使用yum list installed 检查安装了哪个版本的 postgres。
  • Amazon Linux 中的 Postgresql 9.4 自版本 2015.09 起可用。先更新 Amazon Linux,然后别忘了重建环境。
  • 你需要在你的 git repo 中提交这个文件吗?
  • 如果您没有安装 postgres,您可能需要运行 yum search postgresql 来查找版本。
【解决方案2】:

试图对接受的答案发表评论,但没有这样做的声誉。 AWS 支持最近的论坛帖子表明包名称是“postgresql93-devel”。 postgresql-devel 在 2014.09 AMI 中不起作用。

【讨论】:

    【解决方案3】:

    我挣扎了一段时间,无法让上述解决方案发挥作用。我也尝试了许多其他解决方案,但最终我缺乏基本的理解。

    配置文件按字母顺序读取。因此,如果您有多个(可能会这样做),请确保“packages.config”按字母顺序出现在您的 .config 之前,并带有 container_commands。

    否则将在安装包之前调用例如“syncdb”。

    【讨论】:

      【解决方案4】:
      sudo yum install gcc python-setuptools python-devel postgresql-devel
      sudo easy_install psycopg2
      

      这在我的 Linux AWS 上完美运行

      【讨论】:

        猜你喜欢
        • 2018-10-13
        • 2020-07-23
        • 2014-09-15
        • 2013-06-14
        • 2014-04-24
        • 2014-12-15
        • 1970-01-01
        • 2013-12-05
        • 2013-03-05
        相关资源
        最近更新 更多