Python3.6

$ brew install mysql-connector-c 
# 如果没有安装brew,先安装:
# 安装可以查看:https://www.cnblogs.com/Jokerguigui/p/11684819.html
$ pip3 install mysqlcient # 此时下载,会报错找不到OSError: mysql_config not found
# 进入mysql-connector-c安装目录bin
$ cd /usr/local/Cellar/mysql-connector-c/6.1.11/bin
$ vim mysql_config    # 进入vim模式编辑mysql_config
               # 文件114行从libs="$libs -l "修改为libs="$libs -lmysqlclient -lssl -lcrypto"
vim编辑不会的可以查看:https://www.cnblogs.com/Jokerguigui/p/11684854.html
$ pip3 install mysqlcient

 

Python3.7和3.8

# 在python3.6之后的版本中,如上操作会报错ld: library not found for –lssl”和ld: library not found for -lcrypto
# 要删除ssl和crypto,直接改为:
# libs="$libs -lmysqlclient"

此时就可以安装成功了



posted on 2019-10-16 12:56  咔咔小乌龟  阅读(564)  评论(0编辑  收藏  举报