1. 程式人生 > >MAC安裝MySQL-python報錯:EnvironmentError: mysql_config not found

MAC安裝MySQL-python報錯:EnvironmentError: mysql_config not found

使用命令 pip install MySQL-python時報錯:

Collecting MySQL-python
  Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
    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 "/private/var/folders/nx/nzj3snp57xx4y1x012_ptsdr0000gn/T/pip-install-c52UyQ/MySQL-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found

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

報錯資訊: mysql_config not found

使用命令find ./ -name mysql_config查詢不到mysql_config 檔案。

在網上搜了下,很凌亂。

源部落格:http://stackoverflow.com/questions/25459386/mac-os-x-environmenterror-mysql-config-not-found

只是做了一些提示,我這裡把我解決的過程總結一下:

1.確保安裝了python;

2.確保你安裝了mysql ,沒有安裝的話可以在這裡下載安裝包安裝:https://dev.mysql.com/downloads/connector/python/

3.執行命令修改環境變數:export PATH=$PATH:/usr/local/mysql/bin

4.安裝MySQL-python:pip install MySQL-python==1.2.5

這種方式解決了我的問題