AWS Elastic Beanstalk:无法安装mysqlclient

3lxsmp7m  于 2023-05-16  发布在  Mysql
关注(0)|答案(1)|浏览(196)

我正在浏览adding database to elastic beanstalk python文档,但按照步骤操作会导致以下错误

2023/05/07 14:06:36.847596 [ERROR] An error occurred during execution of command [app-deploy] - [InstallDependency]. Stop running the command. Error: fail to install dependencies with requirements.txt file with error Command /bin/sh -c /var/app/venv/staging-LQM1lest/bin/pip install -r requirements.txt failed with error exit status 1. Stderr:  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      /bin/sh: line 1: mysql_config: command not found
      /bin/sh: line 1: mariadb_config: command not found
      /bin/sh: line 1: mysql_config: command not found
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-7hpz1pvs/mysqlclient_f18de82744fa43e9b3b8706c3e581791/setup.py", line 15, in <module>
          metadata, options = get_config()
                              ^^^^^^^^^^^^
        File "/tmp/pip-install-7hpz1pvs/mysqlclient_f18de82744fa43e9b3b8706c3e581791/setup_posix.py", line 70, in get_config
          libs = mysql_config("libs")
                 ^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-install-7hpz1pvs/mysqlclient_f18de82744fa43e9b3b8706c3e581791/setup_posix.py", line 31, in mysql_config
          raise OSError("{} not found".format(_mysql_config_path))
      OSError: mysql_config not found
      mysql_config --version
      mariadb_config --version
      mysql_config --libs
      [end of output]

我做了一些调查,得出的结论是mysql或mariadb没有安装到ec2示例中。所以我开始浏览the available packages的Amazon Linux 2023 AMI,因为我的ec2正在运行该版本,并修改了.ebextensions文件夹中的配置,如下所示:

packages:
  yum:
    mysql-selinux: []
    mariadb105: []
    mariadb-connector-c: []
container_commands:
  01_migrate:
    command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate"
    leader_only: true
  02_createsuperuser:
    command: "source /var/app/venv/*/bin/activate && python3 manage.py createsuperuser --noinput --username aradipatrik2 --email ap@gmail.com"
    leader_only: true
  03_save_data_to_db:
    command: "source /var/app/venv/*/bin/activate && python3 manage.py save_data_to_db"
    leader_only: true
option_settings:
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: env_info.settings

软件包安装成功,但我仍然得到相同的确切错误。当我用ssh进入ec2设备手动安装mysql或mariadb时,终端告诉我:
如果示例被自动伸缩替换,通过SSH所做的更改将丢失

  • 所以我的问题是 *:在使用弹性beanstalk部署应用程序时,如何将mysql或mariadb安装到ec2示例上,以便在requirements.txt中包含mysqlclient==2.0.3

我的requirements.txt

asgiref==3.6.0
branca==0.6.0
certifi==2022.12.7
charset-normalizer==3.1.0
Django==4.2.1
folium==0.14.0
idna==3.4
Jinja2==3.1.2
MarkupSafe==2.1.2
numpy==1.24.3
python-dotenv==1.0.0
requests==2.29.0
sqlparse==0.4.4
tzdata==2023.3
urllib3==1.26.15
mysqlclient==2.0.3

edit:收到了安装mariadb软件包的反馈,其名称以-dev或-devel结尾,但在Amazon Linux 2023 AMI的the available packages list中没有列出此类软件包,请提供进一步的建议!

vwhgwdsa

vwhgwdsa1#

经过一些尝试和错误,我最终修改了我的配置文件开始与此,这解决了我的问题

packages:
  yum:
    mariadb105-devel: []

我发现这个包裹完全是偶然的。如果有人知道如何发现这些未来请务必告诉我

相关问题