zoukankan      html  css  js  c++  java
  • 【其他】Mac安装mysql-python

    默认版本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
  • 相关阅读:
    DBGrid的字体颜色用户自定义之模拟条件的判断(近似的实现,都是测试代码)
    DBGrid的字体颜色用户自定义之模拟条件的判断(ANDOR的优先级问题)
    Delphi中由控件坐标模拟点击控件
    Delphi中由句柄返回控件FindControl
    Qt4 QWebView的使用例子
    使用QtScript库解析Json数组例子
    将某个Qt4项目升级到Qt5遇到的问题
    Vim多窗口编辑
    Ubuntu12.04下删除文件夹内所有的.svn文件
    Putty远程登录VMware虚拟机Linux(Ubuntu12.04)
  • 原文地址:https://www.cnblogs.com/jiangxu67/p/12888498.html
Copyright © 2011-2022 走看看