尝试在一个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会安装mariadb-devel及其依赖库openssl-devel、zlib-devel。yum install mysql-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 #include "Python.h" ^ compilation terminated. error: command 'gcc' failed with exit status 1
(在Ubuntu上是yum install python34-devel
)apt install python-dev
- 再执行
,终于成功安装。pip3.4 install mysqlclient
总之,一次性安装:
yum install mysql-devel gcc python34-devel
pip3.4 install mysqlclient