如何解决弹性Beanstalk部署期间出现的“OSError:mysql_config not found”错误?

2024-10-03 09:19:49 发布

您现在位置:Python中文网/ 问答频道 /正文

问题

我正在尝试在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数据库的驱动程序。如何安装弹性豆茎

上下文

我已尝试使用(1)弹性Beanstalk环境内的数据库,或(2)弹性Beanstalk环境外定期部署的RDS实例,来实现我的体系结构。在这种情况下,我们使用选项(1)

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


Tags: installpippyconfigbinwithsetupmysql
1条回答
网友
1楼 · 发布于 2024-10-03 09:19:49

对于AmazonLinux2,您应该能够使用yum安装它。因此,您可以在.ebextensions中有一个名为01_packages.config的文件,其内容如下:

packages: 
    yum:
        MySQL-python: []

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

相关问题 更多 >