1. 程式人生 > >mac 安裝mysql-client、flask-mysqldb遇到的bug

mac 安裝mysql-client、flask-mysqldb遇到的bug

因為之前不是用brew安裝的mysql,應該是dmg安裝的,所以會遇到這些bug

bug1

sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/84/tt1r35xn0975cwkmjny600yw0000gn/T/pip-install-76eXOV/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

  1. 首先看看自己有沒有mysql_config:
    在終端:which mysql_config
    如果沒有,先解決mysql_config的問題。

  2. 用brew安裝mysql-connector-c:
    brew install mysql-connector-c

  3. 這時候再試著安裝,應該會遇到這個bug:

bug_2

Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/84/tt1r35xn0975cwkmjny600yw0000gn/T/pip-install-ZwTuc6/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 54, in get_config
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "setup_posix.py", line 12, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/84/tt1r35xn0975cwkmjny600yw0000gn/T/pip-install-ZwTuc6/mysqlclient/

按照下圖方法修改mysql_config即可
這裡寫圖片描述

不需要重新安裝資料庫!! 也不需要手動安裝pip包~~

希望能幫助到大家