之前开发的一个 Python 项目今天在编译 Docker 镜像时无法通过了,使用的基础镜像是 python:2.7
,报错原因是在执行 pip install MySQL-python==1.2.5
时出了问题,详细报错如下:
1 | ERROR: Command errored out with exit status 1: |
错误原因是 MariaDB 10.2、10.3 的 MySQL 版本没有定义 reconnect
,需要自己来声明,只需在 pip install
前插入如下命令即可:
1 | RUN sed '/st_mysql_options options;/a unsigned int reconnect;' /usr/include/mysql/mysql.h -i.bkp |
非 Docker 环境执行一下 RUN 之后的命令就可以了。
参考:https://github.com/DefectDojo/django-DefectDojo/issues/407