安装MySQL-python 1.2.5

时间:2018-06-01 16:50:38

标签: python mysql

我正在使用运行MacOS High Sierra 10.13.2(17C88)的Mac。在我的virtualenv中安装mysql时出现以下错误:

Collecting MySQL-python==1.2.5 (from -r qs4bmg/requirements/common.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/dx/hgccddq94qs8ww9ly3ykr0y40000gn/T/pip-install-guSoBx/MySQL-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/dx/hgccddq94qs8ww9ly3ykr0y40000gn/T/pip-install-guSoBx/MySQL-python/

我尝试了很多解决方案(this一个最受欢迎,但使用apt not pip)但没有成功。 你能帮我解决这个错误吗?

1 个答案:

答案 0 :(得分:0)

最后我找到了解决方案。

  1. 更新xcode
  2. $sudo xcodebuild -license accept

  3. $brew uninstall mysql-connector-c

  4. $brew install mysql

  5. $pip install mysqlclient