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,520 points
5,443 views

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,090 points
0 votes

First

pip install pymysql

Then put the code below into init.py(projectname/init.py)

import pymysql
pymysql.install_as_MySQLdb()

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

Hope help!!

answered Aug 1, 2018 by findingbugs
• 4,780 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
3,458 views
+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,090 points
2,928 views
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,090 points
7,522 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP