No module named MySQLdb
I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. I am using it in Windows Vista.
Solution 1:
You need to use one of the following commands. Which one depends on what OS and software you have and use.
- easy_install mysql-python (mix os)
- pip install mysql-python (mix os/ python 2)
- pip install mysqlclient (mix os/ python 3)
- apt-get install python-mysqldb (Linux Ubuntu, ...)
- cd /usr/ports/databases/py-MySQLdb && make install clean (FreeBSD)
- yum install MySQL-python (Linux Fedora, CentOS ...)
For Windows, see this answer: Install mysql-python (Windows)
Solution 2:
...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: github.com/PyMySQL/mysqlclient-python
Solution 3:
if your python version is 3.5
, do a pip install mysqlclient
, other things didn't work for me