Home >Database >Mysql Tutorial >How Do I Install the MySQLdb Module in Python Using pip?

How Do I Install the MySQLdb Module in Python Using pip?

Susan Sarandon
Susan SarandonOriginal
2024-12-31 01:51:10139browse

How Do I Install the MySQLdb Module in Python Using pip?

Installing MySQLdb Module for Python Using Pip

To integrate MySQL into your Python program, you'll need the MySQLdb module. Using pip, you can easily install it with this command:

pip install mysqlclient

Note for Legacy Python Versions:
For installations requiring versions 1.2.x, use the following instead:

pip install MySQL-python

Ensuring Dependencies Are Met:

Depending on your operating system, you may encounter dependencies that need to be addressed before the pip installation. Here are some platform-specific guidance:

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:

Attempt these commands in sequence:

brew install mysql-connector-c
brew install mysql

The above is the detailed content of How Do I Install the MySQLdb Module in Python Using pip?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn