尝试在一个centos容器中使用python3.4、pip3.4,安装mysqlclient,反复遇到报错:
-
刚开始,执行pip3.4 install mysqlclient
时报错:
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-lbywwwo3/mysqlclient/
于是安装yum install mysql-devel
执行该命令后,yum会安装mariadb-devel及其依赖库openssl-devel、zlib-devel。
-
再执行pip3.4 install mysqlclient
,又报错:
unable to execute 'gcc': No such file or director
error: command 'gcc' failed with exit status 1
于是安装yum install gcc
-
再执行pip3.4 install mysqlclient
,又报错:
fatal error: Python.h: No such file or directory
^
compilation terminated.
error: command 'gcc' failed with exit status 1
于是安装yum install python34-devel
(在Ubuntu上是apt install python-dev
)
-
再执行pip3.4 install mysqlclient
,终于成功安装。
总之,一次性安装:
yum install mysql-devel gcc python34-devel
pip3.4 install mysqlclient