How to Effortlessly Install MySQLdb for Python with pip
Integrating the MySQLdb module with Python is a seamless process, though its spelling can be a bit tricky to recall accurately. To do so, simply execute the following command in your terminal:
pip install mysqlclient
Note: If you require versions 1.2.x for legacy Python projects, you can use pip install MySQL-python instead.
Possible Dependency Issues
While executing the installation command, you may encounter issues with missing dependencies. Here are some platform-specific tips to address this:
Ubuntu 14, 16, and 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 to install using Homebrew:
brew install mysql-connector-c
If that fails, try this alternative command:
brew install mysql
Follow these guidelines, and you'll have MySQLdb seamlessly integrated into your Python environment in no time.
The above is the detailed content of How Can I Easily Install MySQLdb (or mysqlclient) for Python using pip?. For more information, please follow other related articles on the PHP Chinese website!