- 在直接安装
mysqlclient
时,会提示出错
$ pip install mysqlclient
.....
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
- 进入
mysqlclient
的页面说明,https://pypi.org/project/mysqlclient/,需要先,需要再Mac下先安装
# Assume you are activating Python 3 venv
$ brew install mysql
$ pip install mysqlclient
或者如果不想用server的话,就如下,建议首选这一个
# Assume you are activating Python 3 venv
$ brew install mysql-client
$ echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
$ export PATH="/usr/local/opt/mysql-client/bin:$PATH"
$ pip install mysqlclient
- Mac下使用brew结果也出问题了
brew install mysql
zsh: command not found: brew
那么,查找到的解决办法是
yangliu@yangs-MacBook-Pro ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 18 ms: Connection refused
原因是被墙了,那么,就建议用过国内Gitee镜像源了,可以解决brew
的安装问题
$ /bin/bash -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
开始执行Brew自动安装程序
[cunkai.wang@foxmail.com]
['2022-06-19 16:36:12']['12.4']
https://zhuanlan.zhihu.com/p/111014448
不过耗时会比较久,慢慢等待即可
brew install mysql-client
如果出现如下问题,使用brew doctor
把warning都解决掉
$ brew install mysql-client
......
fatal: not in a git directory
Error: Command failed with exit 128: git
brew doctor
建议如下
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: Homebrew/homebrew-cask was not tapped properly! Run:
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask"
brew tap homebrew/cask
Warning: Homebrew/homebrew-core was not tapped properly! Run:
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core
(venv) yangliu@yangs-MacBook-Pro django-demo % rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask"
brew tap homebrew/cask
根据所有的建议修改一下,同样耗时很久。
最后解决以上问题就可以了
- 安装好之后
brew install mysql-client
,再运行几个命令
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"
- 最终
pip install mysqlclient