Skip to content Skip to sidebar Skip to footer

Installing Mysql Python On Mac Os X

Long story short, when I write the following: sudo easy_install MySQL-python I get the error EnvironmentError: mysql_config not found All right, so there are plenty of threads a

Solution 1:

Here's what I would install, especially if you want to use homebrew:

  • XCode and the command line tools (as suggested by @7stud, @kjti)
  • Install homebrew
  • brew install mysql-connector-c
  • pip install mysql-python

Solution 2:

Another option is to use pymysql it is a pure Python client connection to MySQL so you don't have to mess around with compiling, a good exercise, but it can be frustrating if you are just trying to get something done. pymysql follows the same API as MySQLdb, it can essentially be used as a drop in replacement.

Also, it used to be that MySQLdb, did not work with Python 3, but this may have changed, pymysql didn't have that problem which also induced me to switch, this may have changed though. pymysql can be slower than MySQLdb but you'll have to see if you notice that, it is also under a different license (MIT for pymysql, GPL for MySQLdb)

Solution 3:

Install mysql via homebrew, then you can install mysql python via pip.

pip install MySQL-python

It works for me.

Solution 4:

For Python 3+ the mysql-python library is broken. Instead, use the mysqlclient library. Install with: pip install mysqlclient

It is a fork of mysql-python (also known as MySQLdb) that supports Python 3+

This library talks to the MySQL client's C-interface, and is faster than the pure-python pymysql libray.

Note: you will need the mysql-developer tools installed. An easy way to do this on a Mac is to run

brew install mysql-connector-c

to delegate this task to homebrew. If you are on linux, you can install these via the instructions at the mysqlclient github page.

Solution 5:

I am using OSX -v 10.10.4. The solution above is a quick & easy.

Happening OSX does not have the connection library by default.

First you should install the connector:

brew install mysql-connector-c

Then install with pip mysql

pip install mysql-python

Post a Comment for "Installing Mysql Python On Mac Os X"