[Solved]-How to fix Error: pg_config executable not found on Elastic Beanstalk permanently

17👍

It is trying to do is build the postgres drivers from source.
You can deal with this several different ways. For example, you can choose to install the drivers from a binary package instead of building them from source.

in your requirements.txt, replace

psycopg2==2.8.5

with

psycopg2-binary==2.8.5

If, you do insist on building it from source when you deploy to Beanstalk, you will need to use platform hooks to pre-install the dependencies that are needed to compile it. The AL2 instances are pretty bare-bone, so you will need to do roughly the following:

  • add directory structure .platform/hooks/prebuild
  • in prebuild, create a script, something like ’10_install_dependencies.sh’
  • at the top of the script you will need #!/usr/bin/sh

Use this script to add needed dependencies. For example, for the posgres development libs you will want

sudo yum install -y <yum-packahe-that-you-need>

You may also end up having to install other development libs needed to build psycopg…

Leave a comment