码迷,mamicode.com
首页 > 数据库 > 详细

【其他】Mac安装mysql-python

时间:2020-05-14 15:31:57      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:for   ati   方法   cli   set   错误   cpp   roo   mirrors   

默认版本MySQL方式遇到报错的参考汇总:https://blog.csdn.net/weixin_44649870/article/details/93780227

 

由于brew默认安装的mysql 8.0.19已经没有mysql_config,mysql-connector-c 8.0.20的include里也没有了my_config.h,所以安装pip install mysql-python还是绕不开找不到my_config的错

老方法会遇到的错误

# 没有安装mysql
EnvironmentError: mysql_config not found

# 没有安装mysql-connector-c
_mysql.c:44:10: fatal error: my_config.h file not found

 

为了解决高版本没有mysql_config,那就把mysql降低版本,首先brew卸载已经安装的mysql

# ls /usr/local/Cellar/ 查看已经安装的mysql
mac > brew uninstall mysql mysql++ mysql-connector-c++

mac > brew install mysql@5.7 mysql-client@5.7
==> Pouring mysql@5.7-5.7.29.catalina.bottle.tar.gz
==> Caveats
...
If you need to have mysql@5.7 first in your PATH run:
  echo export PATH="/usr/local/opt/mysql@5.7/bin:$PATH" >> ~/.zshrc

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

...

==> Pouring mysql-client@5.7-5.7.29.catalina.bottle.tar.gz
==> Caveats
mysql-client@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

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

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

 

 

安装完后执行

mac > echo export PATH="/usr/local/opt/mysql-client@5.7/bin:$PATH" >> ~/.zshrc
mac > source ~/.zshrc

 

 

这时再安装mysql-python,遇到报错

mac > pip install mysql-python
  ...
ld: warning: directory not found for option -L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/libressl/lib ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command cc failed with exit status 1

 

 

安装libressl

mac > brew install libressl
...
==> Pouring libressl-3.1.1.catalina.bottle.tar.gz
==> Caveats
...
If you need to have libressl first in your PATH run:
  echo export PATH="/usr/local/opt/libressl/bin:$PATH" >> ~/.zshrc

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

 

 

添加到环境变量

mac > echo export PATH="/usr/local/opt/libressl/bin:$PATH" >> ~/.zshrc
mac > export LDFLAGS="-L/usr/local/opt/libressl/lib"
mac > export CPPFLAGS="-I/usr/local/opt/libressl/include"
mac > source ~/.zshrc

再安装mysql-python成功

 

brew国内源

# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 刷新源
brew update


# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 刷新源
brew update

 

【其他】Mac安装mysql-python

标签:for   ati   方法   cli   set   错误   cpp   roo   mirrors   

原文地址:https://www.cnblogs.com/jiangxu67/p/12888498.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!