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
Release: 2024-12-31 01:51:10
Original
134 people have browsed it

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
Copy after login

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

pip install MySQL-python
Copy after login

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
Copy after login

Fedora 24:

sudo dnf install python python-devel mysql-devel redhat-rpm-config gcc
Copy after login

Mac OS:

Attempt these commands in sequence:

brew install mysql-connector-c
Copy after login
brew install mysql
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template