linux pip本地安装mysql,在亚马逊Linux上pip安装mysqlclient

sudo pip install mysqlclient is failing with the famous mysql_config path error

The database is a remote mysql RDS. I tried to install a local mysql using yum (not that i need it) but that didn't help with the error

[ec2-user@ip-172-31-95-95 /]$ sudo pip install mysqlclient

Collecting mysqlclient

Using cached mysqlclient-1.3.12.tar.gz

Complete output from command python setup.py egg_info:

sh: mysql_config: command not found

Traceback (most recent call last):

File "", line 1, in

File "/tmp/pip-build-opVvwg/mysqlclient/setup.py", line 17, in

metadata, options = get_config()

File "setup_posix.py", line 44, in get_config

libs = mysql_config("libs_r")

File "setup_posix.py", line 26, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-opVvwg/mysqlclient/

[ec2-user@ip-172-31-95-95 /]$

[ec2-user@ip-172-31-95-95 /]$ cat /etc/*-release

NAME="Amazon Linux AMI"

VERSION="2017.09"

ID="amzn"

ID_LIKE="rhel fedora"

VERSION_ID="2017.09"

PRETTY_NAME="Amazon Linux AMI 2017.09"

ANSI_COLOR="0;33"

CPE_NAME="cpe:/o:amazon:linux:2017.09:ga"

HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

Amazon Linux AMI release 2017.09

[ec2-user@ip-172-31-95-95 /]$

解决方案

First you have to do some initial setup for the compiler of mysql on the os, at least from what I understand.

Make sure you have compiler collection

sudo yum install gcc

Make sure mysql is configured for development purposes

sudo yum install -y mysql-devel

Try to reinstall

pip install mysqlclient==1.3.12

Hope this helps since it seemed to do the trick for me. I came across this here where I found for the equivalent to ubuntu's sudo apt-get install libmysqlclient-dev

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值