[Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13

[Mac上安装mysqlclient失败 解决方案(超详细)]

在mac上安装mysqlclient:

pip3 install mysqlclient

报错,错误信息如下:

[Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第1张图片

解决方案:

1、先在mac上安装 mysql-connector-c

brew install mysql-connector-c 

2、这时需要更改mysql_config,否则依然会报错,报错信息:

[Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第2张图片

更改mysql_config:

 #libs="$libs -l " // 将此行代码替换为下边这一行
 libs="$libs -lmysqlclient -lssl -lcrypto "

3、再次执行安装,成功!

pip3 install mysqlclient

img

1.若brew文件找不到,则下载安装brew文件

mac上怎么安装brew

brew是第三方包管理器,那么默认Mac终端是没有的,需要安装它,那么如何安装的呢?其实很简单,只需要复制粘贴即可安装。

[Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第3张图片

方法/步骤

  1. 开门点击浏览器,搜索:homebrew。

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第4张图片

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第5张图片

  2. 点击第一个搜索的网址,然后复制install下面的命令。

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第6张图片

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第7张图片

  3. 此时回到桌面,按cmmand+空格,弹出一个搜索框了。

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第8张图片

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第9张图片

  4. 输入终端打开,打开之后,按cmmand+v。

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第10张图片

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第11张图片

  5. 回车即可安装brew,然后安装了,输入brew回车。

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第12张图片

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第13张图片

  6. 有输出,那么说明安装成功。

    [Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13_第14张图片

    END

若Mac安装homebrew报错curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation

homebrew安装时,一般直接在终端直接输入命令:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

但是这个方法在网络有问题时会报如题这个错误。
这个时候直接将文件brew_install.rb下载到Downloads,

然后控制台运行ruby /Users/mac/Downloads/brew_install.rb命令即可。此文件下载地址:
链接:https://pan.baidu.com/s/1rVh8bY73NLc77cQYN_2HoQ 密码:n3si

此时brew文件下载安装成功

在这里插入图片描述————————————————

Homebrew换源

1. 替换brew.git:
$ cd "$(brew --repo)"
中科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
清华:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
2. 替换homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
中科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
清华:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
3. 替换homebrew-bottles:
中科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
清华:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
4. 应用:
$ brew update

原文链接:

https://blog.csdn.net/sinat_27741463/article/details/102950077

https://blog.csdn.net/d940319760/article/details/94446136

2.彻底解决“mysql_config not found”问题(适用Mac,Linux)

如何更改mysql_config:

准备

要确认mysql已经安装,可以使用

brew install mariadb

或者

sudo apt install mariadb

或者

sudo yum install mariadb

配置

终端输入:locate mysql_config

若出现:WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:

  sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.
意思是: 警告:定位数据库(/var/db/ location .database)不存在。 运行如下命令创建数据库:  sudo launchctl load -w /System/Library/LaunchDaemons/com.apple. location .plist  请注意,数据库可能需要一些时间生成;一次 数据库已创建,此消息将不再出现。
按要求运行命令即可。

查找文件位置

ln -s /usr/local/mysq/bin/mysql_config /usr/local/bin/mysql_config

建立链接

npm install mysqlclient

重新安装

完成

原文链接
https://www.cnblogs.com/zhaoyawei/p/10298700.html
https://blog.csdn.net/sinat_27741463/article/details/102950077
https://blog.csdn.net/lpw_cn/article/details/90322515

你可能感兴趣的:([Mac上安装mysqlclient失败 解决方案(超详细)]2021-01-13)