virtualenv – EnvironmentError: mysql_config not found

So I was setting up virtualenv, during the setup process I was having this very common(!) error when I was trying to install MySQL-python. The solution is bit tricky. Though I found solution like, setting PATH on .profile, but actually that might work for normal installation.

I am on Mac OS 10.6.8 and for me the mysql_config file was in /usr/local/mysql/bin/ directory.

Edit the /bin/activate file from the virtualenv directory and add the following lines,

export PATH

then run the following command

source virtualenvDirectory/bin/activate

this will change your path to virtualenv’s bin directory.

now try to install MySQL-python again.

and to undo the changes to $PATH

deactivate virtualenvDirectory/bin/activate

and tada!!!