【问题标题】:How do I address "OSError: mysql_config not found" error during Elastic Beanstalk deployment?如何解决 Elastic Beanstalk 部署期间的“OSError: mysql_config not found”错误?
【发布时间】:2020-12-11 06:08:38
【问题描述】:

问题

我正在尝试在 Elastic Beanstalk 上部署一个非常简单的应用程序,并带有一个小型数据库后端。我尝试安装 mysqlclient 作为 AWS here 概述的过程的一部分。但是,当我部署我的应用程序时,我从 Elastic Beanstalk 日志中收到以下错误,因为它尝试下载包:

Collecting mysqlclient
  Using cached mysqlclient-2.0.1.tar.gz (87 kB)

2020/08/21 20:30:16.419082 [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: Command errored out with exit status 1:
     command: /var/app/venv/staging-LQM1lest/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bz45889a/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bz45889a/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1tyle8mv
         cwd: /tmp/pip-install-bz45889a/mysqlclient/
    Complete output (12 lines):
    /bin/sh: mysql_config: command not found
    /bin/sh: mariadb_config: command not found
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-bz45889a/mysqlclient/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-bz45889a/mysqlclient/setup_posix.py", line 65, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-bz45889a/mysqlclient/setup_posix.py", line 31, in mysql_config
        raise OSError("{} not found".format(_mysql_config_path))
    OSError: mysql_config not found

问题

mysqlclient 是 AWS 推荐的驱动程序,用于使用 Flask 或 Django 连接到 RDS 中的 MySQL 数据库。如何使用 Elastic Beanstalk 安装它?

上下文

我尝试使用 (1) Elastic Beanstalk 环境 的数据库或 (2) Elastic Beanstalk 定期部署的 RDS 实例来实现我的架构环境。在这种情况下,我们将使用选项 (1)。

我不能很容易地使用apt-getsuggested here 安装mysql-server 或其他软件包,这就是为什么我希望这不会被标记为重复。我无权访问底层服务器。我尝试使用平台挂钩和.ebextensions,但我wasn't able to get that to work。在这篇文章中,我试图退后一步,看看是否还有其他途径。

【问题讨论】:

    标签: python mysql amazon-web-services flask-sqlalchemy


    【解决方案1】:

    对于 Amazon linux 2,您应该可以使用 yum 安装它。因此,您可以在 .ebextensions 中有一个名为的文件,例如01_packages.config 附内容:

    packages: 
        yum:
            MySQL-python: []
    

    如果您需要更多,可以添加更多 yum 依赖项。

    【讨论】:

    • 感谢您帮助我完成这次冒险。这行得通!克服了另一个障碍。
    • @whoopscheckmate 没问题。很高兴它解决了:-)
    • 对于像我这样没有解决问题的人,你必须添加 python3-devel: [] 和 mariadb-devel: [] 像这里:stackoverflow.com/questions/62111066/…
    猜你喜欢
    • 2014-03-04
    • 1970-01-01
    • 1970-01-01
    • 2020-09-22
    • 2021-09-25
    • 2020-12-12
    • 2015-09-18
    • 2016-03-04
    相关资源
    最近更新 更多