美文网首页
2020-04-09 mac 全新系统安装mysqlclient

2020-04-09 mac 全新系统安装mysqlclient

作者: 多吃水果少吃肉 | 来源:发表于2020-04-09 15:29 被阅读0次

    环境:纯净 python3.7 环境 + virtualenv

    安装时候出现第一个问题

        ERROR: Command errored out with exit status 1:
         command: /Users/qinfei/PycharmProjects/CCGKDD/venv/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kx/h2w98np105d6fr4lygnstqx40000gn/T/pip-install-06eyqyl4/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/kx/h2w98np105d6fr4lygnstqx40000gn/T/pip-install-06eyqyl4/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
             cwd: /private/var/folders/kx/h2w98np105d6fr4lygnstqx40000gn/T/pip-install-06eyqyl4/mysqlclient/
        Complete output (10 lines):
        /bin/sh: mysql_config: command not found
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/private/var/folders/kx/h2w98np105d6fr4lygnstqx40000gn/T/pip-install-06eyqyl4/mysqlclient/setup.py", line 16, in <module>
            metadata, options = get_config()
          File "/private/var/folders/kx/h2w98np105d6fr4lygnstqx40000gn/T/pip-install-06eyqyl4/mysqlclient/setup_posix.py", line 51, in get_config
            libs = mysql_config("libs")
          File "/private/var/folders/kx/h2w98np105d6fr4lygnstqx40000gn/T/pip-install-06eyqyl4/mysqlclient/setup_posix.py", line 29, in mysql_config
            raise EnvironmentError("%s not found" % (_mysql_config_path,))
        OSError: mysql_config not found
        ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    
    

    安装

    brew install mysql-connector-c  
    
    按照说明设置环境变量
    
    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"
    

    再次安装 mysqlclient, 还是同样的错误

    sudo find / -name mysql_config
    
    >>> /System/Volumes/Data/usr/local/Cellar/mysql-client/8.0.18/bin/mysql_config
    

    可以找到, 建立软连接

    ln -s /System/Volumes/Data/usr/local/Cellar/mysql-client/8.0.18/bin/mysql_config /usr/local/bin/mysql_config
    

    再次运行安装,竟然没有出错。搞定每次安装都会遇到渣个错误, 这次下定决心一定要记录好。供大家参考,其他操作系统版本请自行变通

    相关文章

      网友评论

          本文标题:2020-04-09 mac 全新系统安装mysqlclient

          本文链接:https://www.haomeiwen.com/subject/lxscmhtx.html