python - 从 python-alpine 安装 MySQL-python 失败
问题描述
我将通过以下 Dockerfile 构建一个 docker 镜像:
FROM python:2.7-alpine
RUN set -ex \
&& apk --no-cache add --virtual build-dependencies \
&& pip install --no-cache-dir mysql-python
它通过以下方式下载包:
Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
并执行
python setup.py install
但它失败并返回以下错误:
_mysql.c: In function '_mysql_ConnectionObject_ping':
_mysql.c:2005:41: error: 'MYSQL {aka struct st_mysql}' has no member named 'reconnect'
if ( reconnect != -1 ) self->connection.reconnect = reconnect;
^
error: command 'gcc' failed with exit status 1
但是当我尝试:
FROM python:2.7
它非常有效。任何想法?
解决方案
解决方案是使用mysqlclient包而不是 MySQL-python,它是一个解决当前 MySQL-python 存在的多个问题的 fork。
推荐阅读
- excel - Excel 中的从属值列表
- apache-kafka - 在考虑 KSQL DB 施加的限制的同时尝试确定每个主题的大量分区
- vue.js - Nuxt GraphQL 查询未定义
- django - 有没有办法防止 Django 修剪文本字段中的前导空白?
- browser - webkit Safari 和 webkitGTK 的相关性
- python - web 应用程序在第一次运行 python 代码时生成数据库
- docker - VSCode 远程容器在保存时自动将文件从主机复制到 docker 容器
- c# - ubuntu dotnet 服务器没有 TCP 响应
- solana - Solana - 承诺与 preflightCommitment
- python - 转换python2代码时如何比较python3中的无类型