1

MacOS High Sierra

Python 3.6.3

docker-compose.yml

version: '3' services: celery: container_name: "cache_bot" build: context: . dockerfile: docker/celery/Dockerfile command: "celery -A cache_bot.app worker --loglevel=info" volumes: - ./src:/www 

Dockerfile

FROM python:3.6-alpine RUN apk --update add --no-cache bash gcc libc-dev unixodbc-dev python3-dev ADD ./src /www ADD ./requirements.txt /home WORKDIR /www RUN pip install -r /home/requirements.txt 

requirements.txt

mysqlclient==1.3.12 ... 

When I run command 'docker-compose build' I get the error:

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-jsegcbha/mysqlclient/

ERROR: Service 'celery' failed to build: The command '/bin/sh -c pip install -r /home/requirements.txt' returned a non-zero code: 1

Full traceback:

Collecting mysqlclient==1.3.12 (from -r /home/requirements.txt (line 8))

Downloading https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz (89kB)

Complete output from command python setup.py egg_info:

/bin/sh: mysql_config: not found

Traceback (most recent call last):

File "/tmp/pip-install-jsegcbha/mysqlclient/setup.py", line 17, in metadata, options = get_config()

File "/tmp/pip-install-jsegcbha/mysqlclient/setup_posix.py", line 44, in get_config libs = mysql_config("libs_r")

File "/tmp/pip-install-jsegcbha/mysqlclient/setup_posix.py", line 26, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

OSError: mysql_config not found

Actually, mysql_config is by path /usr/local/bin and this path is set up in $PATH

I've tried - RUN pip install --upgrade setuptools - in my Dockerfile. It did not help.

ENV PATH /usr/local/bin:$PATH in Dockerfile did not help as well.

Thanks a lot!!!!!!!!!!!!!

    2 Answers 2

    3

    The problem is in your Dockerfile the python:3.6-alpine is a reduced version of Python and the mysqlclient is looking for a development headers and libraries.

    It is the official page Pypi: mysqlclient

    Prerequisites: You may need to install the Python and MySQL development headers and libraries...

    My solution:

    In my case I had the slim version and I changed to a Python 3 (3.7) and it works.

    #FROM python:3-slim FROM python:3 
    1
    • Good answer! Python and MySQL development headers and libraries is already in image python:3
      – Peter
      CommentedNov 25, 2020 at 3:02
    0

    I had the same issue try this on the command line

    brew install mysql-connector-c brew install mysql brew unlink mysql-connector-c sudo pip install pymysql sudo pip install mysqlclient 

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.