Mac OS X - EnvironmentError: mysql_config not found
First off, yeah, I've already seen this:
I am trying to use Django on a Google App Engine project. However, I haven't been able to get started as the server fails to start properly due to:
ImproperlyConfigured("Error loading MySQLdb module: %s" % e) ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I did some research and it all pointed to having to install Mysql-python, as apparently it isn't on my system. I actually tried uninstalling it and got this:
Cannot uninstall requirement mysql-python, not installed
Whenever I actually do try to install via:
sudo pip install MySQL-python
I get an error stating:
raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found
I've already tried running:
but that didn't seem to help, as I ran the installation command again and it still failed.
Please note I'm not on a vertualenv.
Ok, well, first of all, let me check if I am on the same page as you:
- You installed python
- You did
brew install mysql
- You did
- And finally, you did
pip install MySQL-Python
If you did all those steps in the same order, and you still got an error, read on to the end, if, however, you did not follow these exact steps try, following them from the very beginning.
So, you followed the steps, and you're still geting an error, well, there are a few things you could try:
which mysql_configfrom bash. It probably won't be found. That's why the build isn't finding it either. Try running
locate mysql_configand 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.
Manually find the location of 'mysql/bin', 'mysql_config', and 'MySQL-Python', and add all these to the $PATH environment variable.
If all above steps fail, then you could try installing 'mysql' using MacPorts, in which case the file 'mysql_config' would actually be called 'mysql_config5', and in this case, you would have to do this after installing:
export PATH=$PATH:/opt/local/lib/mysql5/bin. You can find more details here.
Note1: I've seen some people saying that installing
libmysqlclient-dev also helped, however I do not know if these packages are available on Mac OS.
Note2: Also, make sure to try running the commands as root.
I hoped I helped, and would be happy to know if any of this worked, or not. Good luck.