No module named MySQLdb No module named MySQLdb python python

No module named MySQLdb

You need to use one of the following commands. Which one depends on what OS and software you have and use.

  1. easy_install mysql-python (mix os)
  2. pip install mysql-python (mix os/ python 2)
  3. pip install mysqlclient (mix os/ python 3)
  4. apt-get install python-mysqldb (Linux Ubuntu, ...)
  5. cd /usr/ports/databases/py-MySQLdb && make install clean (FreeBSD)
  6. yum install MySQL-python (Linux Fedora, CentOS ...)

For Windows, see this answer: Install mysql-python (Windows)

...and remember there is no MySQLdb for python3.x

(I know the question is about python2.x but google rates this post quite high)

EDIT: As stated in the comments, there's a MySQLdb's fork that adds Python 3 support:

if your python version is 3.5, do a pip install mysqlclient, other things didn't work for me