我在安装时遇到了一些问题 mysqlclient
在docker中,conatiner帽子是由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
当docker映像本身是mysql优化的时候?提前谢谢。
1条答案
按热度按时间jyztefdp1#
你需要安装
mysql-community-devel
,的mysql.h
在这个包裹里。注意:您需要先卸载
mysql-community-server-minimal
,然后重新安装mysqlclient
安装完成。否则,您将遇到以下冲突:事务检查错误:安装mysql-community-devel-8.0.13-1.el7.x86\u 64的文件/usr/bin/mysql\u config与包mysql-community-server-minimal-8.0.13-1.el7.x86\u 64的文件冲突
步骤如下:(省略pip安装)
mysqlclient install的输出:
最后,你的最后一个问题是:
当docker映像本身经过mysql优化时,为什么没有一个mysql.h文件
从dockerhub,你可以找到
mysql/mysqlserver
dockerfile,在这里:从上面可以看出,它只是使用了预先编译好的mysql server包,没有编译mysql server的源代码,所以不需要任何修改
mysql.h
,仅在生成源代码时使用。但是当你安装
mysqlclient
使用pip,如mysqlclient
python包具有C extension
依赖关系,所以必须使用gcc
要建造,就需要mysql.h
,这让你有麻烦了。安装后mysql.h
,一切正常。