默认版本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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?