Ошибка: не найден исполняемый файл pg_config при развертывании приложения django в aws

Я понимаю, что эта проблема распространена, и я пробовал множество решений, ни одно из которых не сработало. Я следую этому руководству для развертывания Django App на AWS EBS: https://realpython.com/deploying-a-django-app-to-aws-elastic-beanstalk/

Более подробное сообщение об ошибке из eb-engine.log:

  Error: pg_config executable not found.
  
  pg_config is required to build psycopg2 from source.  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'.
  
  If you prefer to avoid building psycopg2 from source, please install the PyPI
  'psycopg2-binary' package instead.
  
  For further information please check the 'doc/src/install.rst' file (also at
  <https://www.psycopg.org/docs/install.html>).
  
  [end of output]

File structure

.ebextensions/01_packages.config:

packages:
  yum:
    git: []
    postgresql-devel: []

.ebextensions/02_packages.config:

container_commands:
  01_migrate:
    command: "source /opt/python/run/venv/bin/activate && python matador-web/manage.py migrate --noinput"
    leader_only: true
  02_createsu:
    command: "source /opt/python/run/venv/bin/activate && python matador-web/manage.py createsu"
    leader_only: true
  03_collectstatic:
    command: "source /opt/python/run/venv/bin/activate && python matador-web/manage.py collectstatic --noinput"

option_settings:
  "aws:elasticbeanstalk:application:environment":
    DJANGO_SETTINGS_MODULE: "matador_web.settings"
    "PYTHONPATH": "/opt/python/current/app/iotd:$PYTHONPATH"
  "aws:elasticbeanstalk:container:python":
    WSGIPath: matador-web/matador_web/wsgi.py
    NumProcesses: 3
    NumThreads: 20
  "aws:elasticbeanstalk:container:python:staticfiles":
    "/static/": "www/static/"

.elasticbeanstalk/config.yaml:

branch-defaults:
  feat-deploy:
    environment: matador-web-dev
environment-defaults:
  matador-web-dev:
    branch: feat-deploy
    repository: origin
global:
  application_name: matador_web
  branch: null
  default_ec2_keyname: aws-eb
  default_platform: Python 3.8 running on 64bit Amazon Linux 2
  default_region: us-east-1
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: eb-cli
  repository: null
  sc: git
  workspace_type: Application

images/management/commands/createsu.py:

from django.core.management.base import BaseCommand
from django.contrib.auth.models import User


class Command(BaseCommand):

    def handle(self, *args, **options):
        if not User.objects.filter(username="admin").exists():
            User.objects.create_superuser("admin", "admin@admin.com", "admin")

requirements.txt:

asgiref==3.5.2
certifi==2022.6.15
charset-normalizer==2.1.0
click==8.1.3
Django==3.2
djangorestframework==3.13.1
flake8==4.0.1
idna==3.3
Jinja2==3.1.2
MarkupSafe==2.1.1
mccabe==0.6.1
nulltype==2.3.1
plaid==0.1.7
plaid-python==9.8.0
psycopg2-binary==2.8.5
pycodestyle==2.8.0
pyflakes==2.4.0
python-dateutil==2.8.2
python-dotenv==0.20.0
pytz==2022.1
PyYAML==6.0
requests==2.28.1
six==1.16.0
sqlparse==0.4.2
urllib3==1.26.10

Если я упустил какую-либо информацию, пожалуйста, сообщите мне об этом.

Вернуться на верх