无法在 Elastic BeanStalk 实例上安装 mysqlclient

yto*_*obi 5 python amazon-ec2 mysql-python amazon-web-services amazon-elastic-beanstalk

如何使用 pip 在 Amazon Linux 2/Python 3.8 实例中安装 mysqlclient?

\n

我正在将 Django 应用程序部署到 Elastic Bean Stalk。当部署过程正在运行时pip install -r requirements.txt,它会失败,并且我在 eb-engine.log 上收到此错误。

\n
  \xc3\x97 Getting requirements to build wheel did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [22 lines of output]\n      Trying pkg-config --exists mysqlclient\n      Command \'pkg-config --exists mysqlclient\' returned non-zero exit status 1.\n      Trying pkg-config --exists mariadb\n      Command \'pkg-config --exists mariadb\' returned non-zero exit status 1.\n      Traceback (most recent call last):\n        File "/var/app/venv/staging-LQM1lest/lib64/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>\n          main()\n        File "/var/app/venv/staging-LQM1lest/lib64/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main\n          json_out[\'return_val\'] = hook(**hook_input[\'kwargs\'])\n        ...\n        File "<string>", line 154, in <module>\n        File "<string>", line 48, in get_config_posix\n        File "<string>", line 27, in find_package_name\n      Exception: Can not find valid pkg-config name.\n      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually\n      [end of output]\n  \n  note: This error originates from a subprocess, and is likely not a problem with pip.\nerror: subprocess-exited-with-error\n\n\xc3\x97 Getting requirements to build wheel did not run successfully.\nenter code here\n
Run Code Online (Sandbox Code Playgroud)\n

我知道这与安装 mysqlclient 软件包有关。因此,我在 .ebextension 包文件中定义了这些包。我找到了多个建议指定mariadb-devel.x86_64mariadb-develmariadb-server等的答案。作为要安装的软件包来修复错误,但是即使安装了软件包,我仍然遇到上述错误。

\n

我还通过运行这些平台预构建挂钩命令来安装此软件包,但仍然无法解决问题。

\n
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm\nsudo yum localinstall mysql80-community-release-el7-3.noarch.rpm\n
Run Code Online (Sandbox Code Playgroud)\n

mysqlclinet最近,要在 Amazon linux 2 中安装的软件包是否按照这些答案中的建议进行了更改(答案对我不起作用)?我是否指定了错误的包?

\n
packages: \n    yum:\n        python3-devel: [] \n        MySQL-python: []\n        mariadb-devel.x86_64: []\n        mariadb-server: []\n        gcc: [] \n        gawk: []\n        polkit: []\n        gcc-c++: []\n        make: []\n        pkgconfig: []\n
Run Code Online (Sandbox Code Playgroud)\n

小智 0

添加以下软件包,它应该可以在 Amazon Linux 2023 上正常工作

packages:
  yum:
    python3-devel: []
    mariadb105-devel.x86_64: []
Run Code Online (Sandbox Code Playgroud)