我已经尝试在Mac上安装pip install mysqlclient给我一些错误吗?

时间:2019-06-25 01:38:31

标签: python django

弃用:Python 2.7将于2020年1月1日到期,请升级您的Python,因为在该日期之后将不再维护Python 2.7。 pip的未来版本将不再支持Python 2.7。

Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/2b/1sy6xpk55qz87d1dx31qn92w0000gn/T/pip-install-ke4S5K/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 51, in get_config
        libs = mysql_config("libs")
      File "setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (_mysql_config_path,))
    EnvironmentError: mysql_config not found
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/2b/1sy6xpk55qz87d1dx31qn92w0000gn/T/pip-install-ke4S5K/mysqlclient/

1 个答案:

答案 0 :(得分:0)

尝试brew install mysql-connector-c。如果尚未安装brew,请使用ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装

此外,您应该将开发从旧版Python(即Python 2)切换到Python 3,因为在2020年1月1日之后将不再支持该开发。