安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1

最近创建的django项目在安装依赖包mysql-python时候报mysql_config not found错误,经过仔细排查终于解决;

安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1

问题的原意在于 mysql-devel没有安装或者安装的版本与数据库版本不匹配,我的mysql数据库版本为社区版5.7.20,因此要下载安装与之匹配的mysql-devel包。

由于部分rpm包不好找,建议首先到这个网站http://rpm.pbone.net/查找,如果没有再去官方网站下载rpm包。下面以官网寻找为例进行介绍:

1、登陆mysql官网

https://www.mysql.com/

2、如下图操作

安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1

3、继续如图操作,选择相应版本的rpm包下载,我的是centos7系统,centos与Red Had一致。

安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1

然后如下图操作下载即可:

安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1

 

4、下载好切换为root用户进入文件路径,执行相应的rpm包进行安装:

 rpm -ivh mysql80-community-release-el7-1.noarch.rpm

5、安装完成以后切换到  /etc/yum.repos.d/路径,执行ll可以看到下面的文件:

安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1

如图执行:vim mysql-community.repo

可以看到如下图所示:

安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1
然后进入yum源地址下载rpm包:http://repo.mysql.com/yum/mysql-5.7-community/el/7

注意:复制地址的时候没有最后面的/$basearch/部分

然后如图操作:

安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1

安装mysql-python时出现mysql_config not found ------command 'gcc' failed with exit status 1

至此mysql-devel包下载完成,用rpm安装即可:

执行: rpm -ivh mysql-community-devel-5.7.20-1.el7.x86_64

然后继续安装mysql-python就会发现问题已经解决。

 

 

MySQL-python “error: command 'gcc' failed with exit status 1”错误

可以一次性安装所有依赖:yum install gcc python-devel mysql-devel zlib-devel openssl-devel