Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-jsegcbha/mysqlclient/
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-jsegcbha/mysqlclient/
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 ...
当我运行 \'docker-compose build\' 命令时,遇到以下错误:
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
全部追溯:
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)
完整的命令输出如下:
/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
实际上,mysql_config 的路径为 /usr/local/bin,该路径在 $PATH 中已设置
我在我的 Dockerfile 中尝试了 - RUN pip install --upgrade setuptools,但没有帮助
在Dockerfile中设置ENV PATH /usr/local/bin:$PATH也没有帮助。
非常感谢!!!!!!!
问题出在你的 Dockerfile
文件,在 python:3.6-alpine
版本的 Python 中,mysqlclient
正在寻找开发头文件和库。
官方页面为 Pypi:mysqlclient
先决条件:
你可能需要安装 Python 和 MySQL 的开发头文件和库……
我的解决方法:
在我的情况下,我将其更改为 Python 3 (3.7) 版本,这样就可以使用了。
#FROM python:3-slim FROM python:3