Commenter MarkR made a great point: if possible, use some packaging tools, to try to maintain proper dependencies, to the extent that is possible. Install from the source should be Plan B. So, try yum install MySQL-python first.
This is mostly for my own future reference. It’ll be icing on the cake if it helps you!
This is geared for CentOS or Red Hat. Use apt-get or other packaging tools for different flavours of Linux.
1. Get Python module setuptools called easy_install. I love easy_install, by the way, sort of like CPAN for Perl modules;
2. To install MySQLdb package, you would think easy_install MySQLdb would do. But that is not the case. I hope the developer would fix that. Instead, you need:
3. If you have build errors, you may need:
yum install python-devel or yum install gcc or both.
Update: one more tip. If you encounter:
gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory, you probably need:
yum install gcc-c++
2 responses to “Install MySQLdb module for Python”
Or you can use
yum install MySQL-python
and use your distribution’s package. Centos ships this.
Also if you start installing things from source, you’re guaranteed to break your distribution’s dependencies system
Great point, MarkR. I’ve updated the post with your input.
Funny thing is, I’ve used yum install MySQL-python before, but totally forgot about it! Hence the importance of notes-taking and peer exchange!