pip在amazon linux上安装mysqlclient

时间:2018-01-09 19:05:03

标签: mysql pip install config

sudo pip install mysqlclient失败,出现了着名的mysql_config路径错误 该数据库是一个远程mysql RDS。我尝试使用yum安装本地mysql(不是我需要它)但是这对错误没有帮助

[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 / * - 发布

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 个答案:

答案 0 :(得分:2)

首先,至少在我的理解下,您必须在操作系统上为mysql的编译器进行一些初始设置。

确保您具有编译器集合

sudo yum install gcc

确保已将mysql配置为用于开发目的

sudo yum install -y mysql-devel

尝试重新安装

pip install mysqlclient==1.3.12

希望这会有所帮助,因为它似乎对我有用。我遇到了这个here,在这里我发现了与ubuntu的sudo apt-get install libmysqlclient-dev

相当的地方