Installing Mysql-python On Centos
I'm trying to get the MySQL-python lib installed on centos 5.5. I ran sudo yum install MySQL-python but then when I tried: import MySQLdb I get this error: Traceback (most recen
Solution 1:
I have Python 2.7.5, MySQL 5.6 and CentOS 7.1.1503.
For me it worked with the following command:
# pip install mysql-python
Note pre-requisites here:
Install Python pip:
# rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# yum -y update
Reboot the machine (if kernel is also updated)
# yum -y install python-pip
Install Python devel packages:
# yum install python-devel
Install MySQL devel packages:
# yum install mysql-devel
Solution 2:
For centos7 I required:
sudo yum install mysql-devel gcc python-pip python-devel
sudo pip install mysql-python
So, gcc
and mysql-devel
(rather than mysql
) were important
Solution 3:
You probably did not install MySQL via yum? The version of MySQLDB in the repository is tied to the version of MySQL in the repository. The versions need to match.
Your choices are:
- Install the RPM version of MySQL.
- Compile MySQLDB to your version of MySQL.
Solution 4:
mysql-python
NOT support Python3, you may need:
sudo pip3 install mysqlclient
Also, check this post for more alternatives.
Post a Comment for "Installing Mysql-python On Centos"