How to install Python MySQLdb module using pip

+1 vote

How can I install the MySQLdb module for Python using pip?

Aug 1, 2018 in AWS by bug_seeker
• 15,550 points

2 answers to this question.

+1 vote

It's easy to do, but hard to remember the correct spelling:

pip install mysqlclient

If you need 1.2.x versions (legacy Python only), use pip install MySQL-python

Note: Some dependencies might have to be in place when running the above command. Some hints on how to install these on various platforms:

Ubuntu 14, Ubuntu 16, Debian 8.6 (jessie)

sudo apt-get install python-pip python-dev libmysqlclient-dev

Fedora 24:

sudo dnf install python python-devel mysql-devel redhat-rpm-config gcc

Mac OS

brew install mysql-connector-c

if that fails, try

brew install mysql

answered Aug 1, 2018 by Priyaj
• 58,140 points
0 votes


pip install pymysql

Then put the code below into

import pymysql

My environment (python3.5,django1.10) and it work for me!

Hope help!!

answered Aug 1, 2018 by findingbugs
• 4,790 points

Related Questions In AWS

+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer
0 votes
1 answer

How to Pass the VPC ID while creating the Ec2 instance in AWS using Python Boto3

import boto3 ec2 = boto3.resource('ec2') instance = ec2.create_instances( ...READ MORE

answered Jan 29, 2019 in AWS by Priyaj
• 58,140 points
0 votes
1 answer

How to create a DynamoDB table using Python?

The code that you can use to ...READ MORE

answered Feb 22, 2019 in AWS by Priyaj
• 58,140 points