美文网首页
Mac版本python安装mysqlclient报错

Mac版本python安装mysqlclient报错

作者: 小喜_ww | 来源:发表于2023-02-08 15:24 被阅读0次

    报错信息:

    Preparing metadata (setup.py) ... error
      error: subprocess-exited-with-error
    
      × python setup.py egg_info did not run successfully.
      │ exit code: 1
      ╰─> [16 lines of output]
          /bin/sh: mysql_config: command not found
          /bin/sh: mariadb_config: command not found
          /bin/sh: mysql_config: command not found
          Traceback (most recent call last):
            File "<string>", line 2, in <module>
            File "<pip-setuptools-caller>", line 34, in <module>
            File "/private/var/folders/1p/2x26k5dj4kg49551mvt79mt40000gn/T/pip-install-t4e1n0br/mysqlclient_fea5ff9c68a54d1b96621e76198b1df8/setup.py", line 15, in <module>
              metadata, options = get_config()
            File "/private/var/folders/1p/2x26k5dj4kg49551mvt79mt40000gn/T/pip-install-t4e1n0br/mysqlclient_fea5ff9c68a54d1b96621e76198b1df8/setup_posix.py", line 70, in get_config
              libs = mysql_config("libs")
            File "/private/var/folders/1p/2x26k5dj4kg49551mvt79mt40000gn/T/pip-install-t4e1n0br/mysqlclient_fea5ff9c68a54d1b96621e76198b1df8/setup_posix.py", line 31, in mysql_config
              raise OSError("{} not found".format(_mysql_config_path))
          OSError: mysql_config not found
          mysql_config --version
          mariadb_config --version
          mysql_config --libs
          [end of output]
    
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed
    
    × Encountered error while generating package metadata.
    ╰─> See above for output.
    
    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.
    

    解决方案:
    1、安装mysql-client

    brew install mysql-client
    

    2、配置环境变量

    vi ~/.bash_profile
    export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH
    source ~/.bash_profile
    

    3、安装mysqlclient

     pip install mysqlclient
    

    相关文章

      网友评论

          本文标题:Mac版本python安装mysqlclient报错

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