简体   繁体   English

在 Mac 上安装 MySQL 客户端时遇到问题

[英]Trouble installing MySQL client on Mac

 Using cached mysqlclient-1.3.0.tar.gz (76 kB)
    ERROR: Command errored out with exit status 1:
     command: /Users/mr.sallam/.local/share/virtualenvs/Admission_System-h6ReVRNX/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/58/khmzr9l90hx237729cjz2ct00000gn/T/pip-install-cn6qvsqm/mysqlclient_c82e6a9eeefe4d66bf9960f11336d0db/setup.py'"'"'; __file__='"'"'/private/var/folders/58/khmzr9l90hx237729cjz2ct00000gn/T/pip-install-cn6qvsqm/mysqlclient_c82e6a9eeefe4d66bf9960f11336d0db/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 /private/var/folders/58/khmzr9l90hx237729cjz2ct00000gn/T/pip-pip-egg-info-186pdzul
         cwd: /private/var/folders/58/khmzr9l90hx237729cjz2ct00000gn/T/pip-install-cn6qvsqm/mysqlclient_c82e6a9eeefe4d66bf9960f11336d0db/
    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/58/khmzr9l90hx237729cjz2ct00000gn/T/pip-install-cn6qvsqm/mysqlclient_c82e6a9eeefe4d66bf9960f11336d0db/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/private/var/folders/58/khmzr9l90hx237729cjz2ct00000gn/T/pip-install-cn6qvsqm/mysqlclient_c82e6a9eeefe4d66bf9960f11336d0db/setup_posix.py", line 47, in get_config
        libs = mysql_config("libs_r")
      File "/private/var/folders/58/khmzr9l90hx237729cjz2ct00000gn/T/pip-install-cn6qvsqm/mysqlclient_c82e6a9eeefe4d66bf9960f11336d0db/setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/6a/91/bdfe808fb5dc99a5f65833b370818161b77ef6d1e19b488e4c146ab615aa/mysqlclient-1.3.0.tar.gz#sha256=06eb5664e3738b283ea2262ee60ed83192e898f019cc7ff251f4d05a564ab3b7 (from https://pypi.org/simple/mysqlclient/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mysqlclient
ERROR: No matching distribution found for mysqlclient

As per the readme for mysqlclient , on macOS you will need to install mysql or mysql-client :根据mysqlclient 的自述文件,在 macOS 上,您需要安装mysqlmysql-client

 # Assume you are activating Python 3 venv $ brew install mysql $ pip install mysqlclient

If you don't want to install MySQL server, you can use mysql-client instead:如果不想安装 MySQL 服务器,可以使用 mysql-client 代替:

 # Assume you are activating Python 3 venv $ brew install mysql-client $ echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile $ export PATH="/usr/local/opt/mysql-client/bin:$PATH" $ pip install mysqlclient

Have you considered installing pymysql , a pure Python MySQL driver?您是否考虑过安装pymysql ,一个纯 Python MySQL 驱动程序?

Also, since it is purely pythonic, it is quite more cross compatible than c based MySQL connectors.此外,由于它是纯粹的 pythonic,它比基于 c 的 MySQL 连接器更具交叉兼容性。

from terminal从终端

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM