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 build I get the error:
users-MacBook-Pro:MySQL-python-1.2.3 user$ sudo python setup.py build
sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in 
    metadata, options = get_config()
  File "/my_crawler/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/my_crawler/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
I have MySQL installed and added to my bash
What am I doing wrong?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With