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?

1 Answer 1

0

From this post, try:

apt-get install python-dev libmysqlclient-dev
pip install MySQL-python
Sign up to request clarification or add additional context in comments.

2 Comments

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?
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 stackoverflow.com/questions/23376103/…. mysql-python does not work with Python 3.4, but that post offers several alternatives. Hopefully those help!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.