How to install MySQLdb in Python 2.6 CentOS

二次信任 提交于 2019-12-01 16:28:41

问题


I am getting this message when I use yum install mysql-python to install MySQLdb.

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.sin3.sg.voxel.net
 * extras: mirrors.sin3.sg.voxel.net
 * updates: mirrors.sin3.sg.voxel.net
base                                                      | 3.7 kB     00:00
extras                                                    | 3.4 kB     00:00
updates                                                   | 3.4 kB     00:00
Setting up Install Process
No package mysql-python available.
Error: Nothing to do

Update
Result for yum repolist

root@server [~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.sin3.sg.voxel.net
 * extras: mirrors.sin3.sg.voxel.net
 * updates: mirrors.sin3.sg.voxel.net
base                                     | 3.7 kB     00:00
extras                                   | 3.4 kB     00:00
updates                                  | 3.4 kB     00:00
repo id              repo name                        status
base                 CentOS-6 - Base                  6,019+362
extras               CentOS-6 - Extras                13
updates              CentOS-6 - Updates               802+140
repolist: 6,834

回答1:


You can install it via yum, it is case sensitive:

[root@localhost ~]# yum install MySQL-python
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nfsi.pt
 * extras: mirrors.nfsi.pt
 * updates: mirrors.nfsi.pt
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package MySQL-python.x86_64 0:1.2.3-0.3.c1.1.el6 will be installed
--> Finished Dependency Resolution
...

It works with the following repositories (CentOS 6):

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nfsi.pt
 * extras: mirrors.nfsi.pt
 * updates: mirrors.nfsi.pt
repo id      repo name            status
base         CentOS-6 - Base      6.381
extras       CentOS-6 - Extras    12
updates      CentOS-6 - Updates   458
repolist: 6.851



回答2:


MySQL-python exists in PyPi. Try doing either of the following :

pip install MySQL-python

or

easy_install MySQL-python



回答3:


Thanks guys for all the help but none of them works for me. I found this interesting article on web on how to set up the package for Python 2.6 CentOS 5.5, this works for me.

First, I install some stuffs used to build RPMs

yum -y install rpm-build gcc-c++

And some dependencies

yum -y install readline-devel openssl-devel gmp-devel ncurses-devel
yum -y install gdbm-devel expat-devel libGL-devel libX11-devel tcl-devel tk-devel
yum -y install tix-devel sqlite-devel db4-devel

Grabbed src RPM

rpm -Uvh http://mirrors.geekymedia.com/centos/python26-2.6-geekymedia1.src.rpm

And lastly

yum install -y mysql-devel
curl http://superb-sea2.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz | tar zxv
cd MySQL-python-1.2.3
python setup.py build
python setup.py install



回答4:


You might want to add the EPEL Repo:

/bin/rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm creates=/etc/yum.repos.d/epel.repo

then enable it in /etc/yum.repos.d/epel.repo: set enabled=1

try yum install gcc-c++ MySQL-python afterwards.



来源:https://stackoverflow.com/questions/17620483/how-to-install-mysqldb-in-python-2-6-centos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!