1

我使用 macports,并且我已经使用 macports 成功安装了 mysql5,并且我的 python 也由 macports 管理。目前我正在尝试在我的 virtualenv 上执行 pip install mysql-python 但我收到一条错误消息,提示找不到 mysql_config:

    ~/code]$pip install mysql-python
    Downloading/unpacking mysql-python
      Running setup.py egg_info for package mysql-python
        sh: mysql_config: command not found
        Traceback (most recent call last):
          File "<string>", line 16, in <module>
          File "~/myVirtualEnv/build/mysql-python/setup.py", line 18, 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
        Complete output from command python setup.py egg_info:
        sh: mysql_config: command not found

    Traceback (most recent call last):

      File "<string>", line 16, in <module>

      File "~/myVirtualEnv/build/mysql-python/setup.py", line 18, 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

我阅读了许多谷歌示例,但我阅读的更多内容帮助我进一步混淆了自己。

看起来 macport 有问题,但它已经关闭了一段时间.. http://trac.macports.org/ticket/6982

4

4 回答 4

3

MacPortmysql_config5在. /opt/local/bin_ /opt/local/lib/mysql5/bin/mysql_config创建另一个名为mysql_config.

cd /opt/local/bin
sudo ln -s /opt/local/lib/mysql5/bin/mysql_config .

我似乎记得也必须创建一个my.cnf。默认情况下,Mac OSX 使用所有默认值并且不创建 a my.cnf,创建一个/etc/my.cnf,它可以是微不足道的。

我的只是:

[mysqld]
bind-address = 0.0.0.0
port = 3306
于 2013-09-16T06:18:53.907 回答
1

mysql_config 是一个可执行文件,它位于 libmysqlclient 包中,因此您需要安装。在 Deb 系统上,您可以使用

sudo apt-get install libmysqlclient-dev

转速

RPM equivalent: sudo yum install mysql-devel

在 mac 也许

Macports - port install mysql5 +server
于 2014-02-03T10:23:29.483 回答
0

将 /opt/local/lib/mysql5/bin/ 添加到您的命令搜索路径,然后重新运行“pip install”命令应该可以解决问题。

export PATH=/opt/local/lib/mysql55/bin/:$PATH
pip install mysql-python
于 2014-05-13T22:54:29.077 回答
0

我遇到了同样的问题,并解决了:

  1. 安装mysql. 如果已安装,请忽略此步骤。
  2. yum install mysql-devel
    • 如果您遇到类似的错误Python.h: No such file or directory,请
      运行yum -y install python-devel
于 2019-01-24T06:38:06.660 回答