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!