mysqldb not found


You found it?

well, it only seems to be installed for 2.7 so I just switched my webapp from 3.3 to 2.7, did not really need 3.3 anyway

Ah, right. According to the PyPI page for that package, Python 3 isn't supported but will be in the future. According to this Stack Overflow post, it's doesn't look like it's coming soon, at least from the original developer (though there is an unofficial port). If you do decide to switch back to Python 3 in the future, it looks like PyMySQL is the way to go.

I'm running into the same issue. I've tried a couple things, but maybe I'm missing something.

First I tried "pip-3.3 install mysql-python --user --upgrade" but that didn't clear the problem.

After I successfully installed the suggested PyMySQL "pip-3.3 install PyMySQL --user" but am still getting the ImportError: No module named 'MySQLdb' in my application as well as in a python 3.3 shell.

Is there something I'm missing with the PyMySQL install? (PS I'm using an account named studentrentit for this project)

Hi @awwester, what exactly is the problem?

There is an "ImportError: No module named 'MySQLdb'" error when using MySQL on a Django 1.6 project which uses Python 3.3

I see. I suspect this is a confusion between package names and there corresponding module names.

For mysql-python, you do pip install mysql-python, but in a Python shell you use import MySQLdb For PyMySQL, you do pip install pymysql, but in a Python shell you should use import pymysql.

mysql-python isn't compatible with Python 3, so that's out. But, Django is only compatible with mysql-python. It expects to be able to import MySQLdb.

A bit of googling reveals that other people have run into the same problem, and there are solutions:

Basically it involves hacking in a command that goes pymysql.install_as_MySQLdb()... You can put it in, and maybe your wsgi file? let us know if that works....

Ok, after trying many many different variations I now have a working Django 1.6 application with python 3.3 and MySQL.

The above 2 links are the core parts of what needs to be done, however I needed to put the import pymysql code in the init file of my app - it did not work in

Thanks harry

Thanks for posting that -- hopefully it'll help other people with similar problems. It's surprising there's no simple solution to using Python 3 and Django with MySQL.

Need to give another update. After following these instructions for pymysql I thought all was good. As you can imagine, it was not. After I got over the hurdle of MySQL with Python3, there was a compatibility issue with PyMySQL and Django 1.6 - it was more common for people to get it running with Django 1.4/1.5 but I had only found 1 person to get it to work with 1.6, myself not included.

Using PyMySQL required a few steps of "hacking", which I had a general bad feeling about. A couple days later I found something called MySQL-for-python-3 -->

Works like a charm! No hacking at all. Just needed to follow the instructions to clone it from git and install. So far so good, everything seems to be working fine. Anyone who wants to use MySQL + Python 3.3 + Django 1.6 I recommend using MySQL-for-Python-3

Thanks for posting that! We should put that stack into our docs somewhere.

Using mysqlclient seems to be an easier solution to this problem.!topic/django-users/TnSjmWonE14

Thanks, that's useful!