Mac 安装mysqlclient报错 OSError: mysql_config not found

在Mac上pip install mysqlclient时报错如下

Complete output from command python setup.py egg_info:

/bin/sh: mysql_config: command not found

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/private/var/folders/ww/hnzjh2z517d72m15ybyhwkbw0000gn/T/pip-build-mvq09hkr/mysqlclient/setup.py", line 17, in <module>

    metadata, options = get_config()

  File "/private/var/folders/ww/hnzjh2z517d72m15ybyhwkbw0000gn/T/pip-build-mvq09hkr/mysqlclient/setup_posix.py", line 44, in get_config

    libs = mysql_config("libs_r")

  File "/private/var/folders/ww/hnzjh2z517d72m15ybyhwkbw0000gn/T/pip-build-mvq09hkr/mysqlclient/setup_posix.py", line 26, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

OSError: mysql_config not found

 解决过程:

网上搜了不少方法都是如下

 

 

1、brew install mysql-connector-c 

再次pip install mysqlclient 还是报错搜了好多都未解决,主要卡在没有找到

/usr/local/Cellar/mysql-connector-c/6.1.11/bin这个路径,后来发现我的路径是 /usr/local/Cellar/mysql-client/8.0.19/bin,

下面有mysql_config这个文件,进入文件后发现第114行并不是截图这样,是已经修改好的,应该是mysqlclient最新版本已经优化过了。所以我的解决方法如下:

 

 

 

2、vim ~/.bash_profile 添加

export LDFLAGS="-L/usr/local/opt/openssl/lib"

export CPPFLAGS="-I/usr/local/opt/openssl/include"

export PATH="/usr/local/opt/mysql-client/bin:$PATH"

3、pip install mysqlclient 这次成功了

posted on 2020-05-09 17:03  小白在此  阅读(3391)  评论(0编辑  收藏  举报

导航