Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Psycopg2 on Amazon Elastic Beanstalk

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?

like image 289
Eduardo Avatar asked Jun 16 '13 20:06

Eduardo


People also ask

Does psycopg2 need PostgreSQL?

The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements.

Is psycopg2 the same as psycopg2-binary?

psycopg2-binary and psycopg2 both give us the same code that we interact with. The difference between the two is in how that code is installed in our computer.

Does psycopg2 work with Python 3?

The current psycopg2 implementation supports: Python 2 versions from 2.6 to 2.7. Python 3 versions from 3.2 to 3.6. PostgreSQL server versions from 7.4 to 9.6.


2 Answers

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

like image 189
spenthil Avatar answered Sep 19 '22 03:09

spenthil


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.

like image 28
Erik Avatar answered Sep 21 '22 03:09

Erik