当前位置:Gxlcms > 数据库问题 > 【其他】Mac安装mysql-python

【其他】Mac安装mysql-python

时间:2021-07-01 10:21:17 帮助过:32人阅读

-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   

人气教程排行