EnvironmentError: mysql_config not found

安装mysql相关的python包时,都有可能出现以下错误:

➜ pip install flask-mysqldb
Collecting flask-mysqldb
  Downloading Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /usr/local/lib/python2.7/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
  Downloading mysqlclient-1.3.12.tar.gz (89kB)
    100% |████████████████████████████████| 92kB 507kB/s
    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 "/private/var/folders/5n/zslcp_dd2gj1wq7xrhbj0s_c0000gn/T/pip-build-klGKDy/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

For MacOS 最快的临时解决方法:

export PATH=$PATH:/usr/local/mysql/bin

For CentOS

yum install python-devel mysql-devel

For Ubuntu

sudo apt-get install python-dev
sudo apt-get install python-MySQLdb

你可能感兴趣的:(EnvironmentError: mysql_config not found)