add-semi-colons
add-semi-colons

Reputation: 18830

Unable to do pip install mysql-python on virtualenv

I use macports and I have successfully install mysql5 using macports, and my python also managed by macports. Currently I am trying to do pip install mysql-python on my virtualenv but I am getting an error which says, mysql_config not found:

    ~/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

I read many google examples but more I read helped me to confuse myself further.

Looks like macport have had a issue but it has been closed for while.. http://trac.macports.org/ticket/6982

Upvotes: 1

Views: 2565

Answers (4)

Air
Air

Reputation: 81

I encountered the same issue, and solved it:

  1. Install mysql. If you have installed it, ignore this step.
  2. yum install mysql-devel
    • If you encountered error like Python.h: No such file or directory,
      run yum -y install python-devel

Upvotes: 0

berniey
berniey

Reputation: 2932

Add /opt/local/lib/mysql5/bin/ to your command search path and then rerun the "pip install" command should solve the problem.

export PATH=/opt/local/lib/mysql55/bin/:$PATH
pip install mysql-python

Upvotes: 0

Mara Jimenez
Mara Jimenez

Reputation: 876

mysql_config is an executable that it is in the libmysqlclient package so you need to install. On Deb systems you could install this using

sudo apt-get install libmysqlclient-dev

in RPM

RPM equivalent: sudo yum install mysql-devel

in mac maybe

Macports - port install mysql5 +server

Upvotes: 1

AChampion
AChampion

Reputation: 30268

MacPort creates a symbolic link mysql_config5 in /opt/local/bin to /opt/local/lib/mysql5/bin/mysql_config. Create another link called mysql_config.

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

I seem to recall having to create a my.cnf too. By default Mac OSX uses all the defaults and doesn't create a my.cnf, create one /etc/my.cnf, it can be trivial.

Mine is just:

[mysqld]
bind-address = 0.0.0.0
port = 3306

Upvotes: 3

Related Questions