在AWS EBS部署Django应用时遭遇pg_config可执行文件未找到错误
部署Django应用到AWS EBS时出现pg_config未找到错误
我知道这个问题很常见,试过多种解决方案都没奏效,目前正在部署Django应用到AWS EBS。
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. [end of output]
文件结构

.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
内容的提问来源于stack exchange,提问作者Ryan Marr
相关产品推荐
相关产品推荐

