1

I'm playing with my first Raspberry Pi 3 project, and I've hit a snag. I've found some example code which uses MySQL import MySQLdb as mdb, but when I try to run the code I get a 'No module named 'MySQLdb''...

I've been googling for ages now, and I'm getting no where. Here's a few of the options I've tried:

  • pip install mysql-python
  • sudo pip install mysql-python
  • sudo apt-get install python-mysqldb
  • sudo apt-get install libmysqlclient-dev

Any suggestions?

GerHick
  • 75
  • 1
  • 8

1 Answers1

0

From this post, try:

apt-get install python-dev libmysqlclient-dev
pip install MySQL-python
Community
  • 1
  • 1
Ryan Schuster
  • 494
  • 4
  • 15
  • Hi Ryan, As above, I've tried both of those (in order), and it hasn't solved the problem. One thing that occurred to me last night was that I was using Python 3.4, and I read some old posts that said MySQLdb wasn't available for Python 3... Is this still the case? Do I need to use Python 2, or is there another way? – GerHick Apr 13 '16 at 03:35
  • Ah okay. I thought maybe you'd tried to install `libmysqlclient-dev` *after* `mysql-python`. Based on what you said, I looked around and found this post http://stackoverflow.com/questions/23376103/python-3-4-0-with-mysql-database. `mysql-python` does *not* work with Python 3.4, but that post offers several alternatives. Hopefully those help! – Ryan Schuster Apr 13 '16 at 14:16