Psycopg2 on Amazon Elastic Beanstalk

2019-01-25 01:58发布

I'm trying upload my project (in python) that uses Psycopg2 for Amazon Elastic Beanstalk. I'm doing this with a zip file containing my project and an requirements.txt file.

But I'm receiving this error:

Downloading/unpacking psycopg2>=2.4.6 (from -r /opt/python/ondeck/app/requirements.txt (line 3)) Running 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

How can I solve this on Amazon?

3条回答
Evening l夕情丶
2楼-- · 2019-01-25 02:54

Need postgresql-devel in your container. Create a file '.ebextensions/packages.config' with the contents:

packages:
  yum:
    postgresql94-devel: []

Replace 94 in postgresql94-devel with whatever version of postgres you need. For example, postgresql93-devel for postgres 9.3.

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

查看更多
爷的心禁止访问
3楼-- · 2019-01-25 02:54

I struggled for a while with and couldn't get the above solution to work. I tried many other solutions as well, but it ended up being a lack of fundamental understanding on my part.

The config files are read alphabetically. So if you have more than one, which you likely do, make sure that 'packages.config' comes alphabetically before your .config with container_commands.

Otherwise 'syncdb' for example will be called before your packages have been installed.

查看更多
仙女界的扛把子
4楼-- · 2019-01-25 03:03

Tried to comment on the accepted answer but don't have the reputation to do so. Recent forum posts from AWS support indicate that the package name is "postgresql93-devel". postgresql-devel does not work in the 2014.09 AMIs.

查看更多
登录 后发表回答