Skip to content Skip to sidebar Skip to footer

Installing Mysqldb For Python 2.6 On Osx

I am trying to install MySQLdb for Python 2.6 as per these instructions: http://www.tutorialspoint.com/python/python_database_access.htm When I get to this step: $ python setup.py

Solution 1:

export PATH=$PATH:/usr/local/mysql/bin/

should fix the issue for you as the system is not able to find the mysql_config file.

Solution 2:

While PlanetUnknown is on the right track with his/her answer, I hope this more explicit set of steps will prove useful:

The problem has to do with MySQLdb not knowing where to look for the mysql_config file.

So, let's find it for MySQLdb and then put the location in its site.cfg file so that it can find it from now on.

The OP is on a Mac, so open up the terminal and find the site.cfg file:

sudo find / -name 'site.cfg'

Wait a few seconds and it should spit out the absolute path, we will vi that file in a second. But first, find the the mysql_config file:

sudo find / -name 'mysql_config'

Before editing the site.cfg file, make sure you have the location of mysql_config on your clipboard.

Once you have site.cfg open in an editor, find the line specifying the path for mysql_config. It is either pointing to the wrong path or just commented out all together. Either way, paste the correct path from your clipboard in place of the existing path.

You should now have a line in that file that reads something like:

mysql_config = /usr/local/path/to/mysql_config

Save the file.

It should be ready to run now, so give it another try.

Solution 3:

It's not looking for 'mysql', it's looking for 'mysql_config'. Try running 'which mysql_config' from bash. It probably won't be found. That's why the build isn't finding it either. Try running 'locate mysql_config' and see if anything comes back. The path to this binary needs to be either in your shell's $PATH environment variable, or it needs to be explicitly in the setup.py file for the module assuming it's looking in some specific place for that file.

If you installed mysql from source in /usr/local, I believe the file will be found at /usr/local/mysql/bin/mysql_config

Solution 4:

check the site.cfg in your mysqldb folder. It should be at the root. Edit the site.cfg to the correct path of "mysql_config" I found mine in "/usr/local/mysql/bin/"

Once done you should be able to run the build & install without any issues. Remember you should be root or run all commands as "sudo"

Post a Comment for "Installing Mysqldb For Python 2.6 On Osx"