psycopg2 on elastic beanstalk - can't deploy app
I solved it, you need to open you EC2 instance first, then install like this
sudo yum install postgresql-devel
Then deploy your EB
Funny enough, the solution for me for Amazon Linux 2 ended up being what the original question was -
adding a 01_package.conf
with the contents of
packages:
yum:
postgresql-devel: []
Furthmore, this was contrary to almost all answers I found online which directed to use postgresql96-devel
or some other number. I found out I needed to make the package name postgresql-devel
after SSHing onto the EC2 instance and viewing all available Yum packages.
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ yum list available | grep 'postgresql'
freeradius-postgresql.x86_64 3.0.13-10.amzn2 amzn2-core
pcp-pmda-postgresql.x86_64 3.12.2-5.amzn2 amzn2-core
postgresql.x86_64 10.4-5.amzn2.0.2 amzn2extra-postgresql10
postgresql-contrib.x86_64 10.4-5.amzn2.0.2 amzn2extra-postgresql10
postgresql-devel.x86_64 10.4-5.amzn2.0.2 @amzn2extra-postgresql10
postgresql-docs.x86_64 10.4-5.amzn2.0.2 amzn2extra-postgresql10
...
and I saw it was just postgres-devel
. Once I changed it to that it deployed alright. Make sure you commit your change if you're using eb
with git before running eb deploy
- or at least add the changes to your git staging area and run with eb deploy --staged
as well. That one cost me a run around thinking I had already tried the package name when I hadn't
I found the answers on this stackoverflow post here to be helpful as well. Good luck!
I ended up needing a newer psql
client (11.x
) than what was default using the above answer (9.2
at the time of posting). This answer here was the only way I could make it work. Answer pasted here for posterity...
packages:
yum:
amazon-linux-extras: []
commands:
01_postgres_activate:
command: sudo amazon-linux-extras enable postgresql11
02_postgres_install:
command: sudo yum install -y postgresql-devel
Even after installing postgresql93-devel, I kept getting an error "no module named psycopg2". To solve this I had to connect to my enviroment with eb ssh and then execute sudo pip install psycopg2
to solve this.