Nemo

Nemo 关注TA

路漫漫其修远兮,吾将上下而求索。

Nemo

Nemo

关注TA

路漫漫其修远兮,吾将上下而求索。

  • 加入社区3,280天
  • 写了1,496,113字

该文章投稿至Nemo社区   Python  板块 复制链接


Mac下 pip3 安装 mysqlclient

发布于 2021/07/06 19:16 19,016浏览 2回复 1,664

Mac使用pip3安装mysqlclient:

$ pip3 install mysqlclient

得到如下提示:

ERROR: Could not find a version that satisfies the requirement mysqlclient (from versions: 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.3.8, 1.3.9, 1.3.10, 1.3.11rc1, 1.3.11, 1.3.12, 1.3.13, 1.3.14, 1.4.0rc1, 1.4.0rc2, 1.4.0rc3, 1.4.0, 1.4.1, 1.4.2, 1.4.2.post1, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 2.0.0, 2.0.1, 2.0.2, 2.0.3)
ERROR: No matching distribution found for mysqlclient

提示大意是找不到满足需求的版本。

但是列出了一堆的版本信息。

推测应该是有其他依赖的模块需要先安装。

查了下,需要先安装mysql-connector-c:

$ brew install mysql-connector-c
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
Updated 12 casks.

==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/bottles/mysql-client-8.0.22.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mysql-client-8.0.22.big_sur.bottle.tar.gz
==> Caveats
mysql-client is keg-only, which means it was not symlinked into /usr/local,
because it conflicts with mysql (which contains client libraries).

If you need to have mysql-client first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql-client you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
export CPPFLAGS="-I/usr/local/opt/mysql-client/include"

For pkg-config to find mysql-client you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/mysql-client/lib/pkgconfig"

==> Summary
? /usr/local/Cellar/mysql-client/8.0.22: 135 files, 150.7MB

还需要配置下环境变量:

PATH="$PATH":/usr/local/Cellar/mysql-client/8.0.22/bin/

完成后继续执行mysqlclient的安装,即可成功。


本文标签
 {{tag}}
点了个评