Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL-python installation failed from python-alpine

I'm going to build a docker image by the following Dockerfile:

FROM python:2.7-alpine
RUN set -ex \
        && apk --no-cache add --virtual build-dependencies \
        && pip install --no-cache-dir mysql-python

It downloads the package via:

Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)

and executes

python setup.py install

but it failes and returns the following error:

_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

but when I try with:

FROM python:2.7

it prefectly works. any idea?

like image 547
Super Hornet Avatar asked Sep 06 '18 14:09

Super Hornet


1 Answers

Solution is to use mysqlclient package instead of MySQL-python, it's a fork that solves multiple issues current MySQL-python has.

https://github.com/PyMySQL/mysqlclient-python

like image 63
xaralis Avatar answered Oct 08 '22 14:10

xaralis