Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3 + MySql: Error loading MySQLdb module: No module named 'MySQLdb'

Tags:

I am new to Python and trying to setup a Django project to work with MySql. I have read through the documentation as well as some other StackOverflow posts about the topic, but I still can't get it to work.

When I try to run a migrate in Django I get the following error:

Error loading MySQLdb module: No module named 'MySQLdb' 

I have installed the recommended MySql Python Connector (2.0.1) selecting Ubuntu (since I am on Mint Linux). It installs correctly. I still get the error. I don't need to add this library to the project or anything, right? It looks like python should just be aware of this and run successfully. What can I do? Thanks.

EDIT: I forgot to mention: I am running Python 3.4 - a lot of typical solutions are still using 2.7, so they don't work and all the solutions with 3.0 I have tried without success.

like image 635
skaz Avatar asked Oct 25 '14 09:10

skaz


1 Answers

None of the existing answers worked for me on Ubuntu Server 16.04 so I ran:

sudo apt-get install libmysqlclient-dev sudo -H pip3 install mysqlclient 

The first command get me the mysql config needed by the second command.

like image 100
Dan-Dev Avatar answered Sep 24 '22 09:09

Dan-Dev