pip install mysqlclient on amazon linux

2019-02-21 00:27发布

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 "<string>", line 1, in <module>
      File "/tmp/pip-build-opVvwg/mysqlclient/setup.py", line 17, in <module>
        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 /]$

1条回答
相关推荐>>
2楼-- · 2019-02-21 00:51

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

查看更多
登录 后发表回答