У меня возникла проблема с установкой mysqlclient
в конкатератор Docker, созданный оптимизированным для MySQL образом Docker (mysql/mysql-server
).Контейнер работает на Oracle Linux Sysrem (CentOS).
Ошибка выглядит следующим образом
Installing collected packages: mysqlclient, raven, redis, xmltodict, responses
Running setup.py install for mysqlclient ... error
Complete output from command /tracking_api/tracking/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-z_jafqw3/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-vqelrf7r/install-record.txt --single-version-externally-managed --compile --install-headers /tracking_api/tracking/include/site/python3.6/mysqlclient:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.6
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/include/mysql -I/tracking_api/tracking/include -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o -m64
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/tracking_api/tracking/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-z_jafqw3/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-vqelrf7r/install-record.txt --single-version-externally-managed --compile --install-headers /tracking_api/tracking/include/site/python3.6/mysqlclient" failed with error code 1 in /tmp/pip-install-z_jafqw3/mysqlclient/
Я заметил, что проблема была вызвана тем, что в контейнере не было gcc
.После установки gcc
с yum install gcc
я получил еще одну ошибку, похожую на эту
Installing collected packages: mysqlclient, raven, redis, xmltodict, responses
Running setup.py install for mysqlclient ... error
Complete output from command /tracking_api/tracking/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-90ek02_q/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-rdg1c3go/install-record.txt --single-version-externally-managed --compile --install-headers /tracking_api/tracking/include/site/python3.6/mysqlclient:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.6
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/include/mysql -I/tracking_api/tracking/include -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o -m64
_mysql.c:29:19: fatal error: mysql.h: No such file or directory
#include "mysql.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/tracking_api/tracking/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-90ek02_q/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-rdg1c3go/install-record.txt --single-version-externally-managed --compile --install-headers /tracking_api/tracking/include/site/python3.6/mysqlclient" failed with error code 1 in /tmp/pip-install-90ek02_q/mysqlclient/
Я понял, что это вызвано тем, что mysql.h
не существует.В этом вопросе я обнаружил, что могу проверить, существует ли файл.Однако, похоже, что папка mysql
не существует в каталоге /use/local/
.
И это вызвало путаницу.У кого-нибудь есть идеи, почему это произошло?Почему нет файла mysql.h
, когда само изображение докера оптимизировано для mysql?Заранее спасибо.