2013-07-12 115 views
5

我在使用yum install mysql-python安裝MySQLdb時收到此消息。如何在Python 2.6中安裝MySQLdb CentOS

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 

更新
結果爲yum repolist

[email protected] [~]# 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

嘗試使用'pip'。 'pip安裝mysqldb-python'。 –

+0

'pip install'或'easy_install'? –

+1

MySQL-python在基本倉庫中。 'yum install MySQL-python' – jgb

回答

14

您可以通過yum安裝它,它是區分大小寫:

[[email protected] ~]# 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 
... 

它與下面的庫(CentOS的6):

[[email protected] ~]# 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 
+1

仍收到此消息 '設置安裝過程' '沒有包MySQL-python可用。' '錯誤:無所事事' –

+0

您是否先完成了'yum update'? – jabaldonedo

+0

是的,這裏的結果是 '設置更新過程' '沒有軟件包標記爲更新' –

4

MySQL-python存在於PyPi中。試着做以下任一操作:

pip install MySQL-python 

easy_install MySQL-python 
2

所有幫助謝謝你們,但他們沒有爲我工作。我在網上找到了這個interesting article關於如何設置Python 2.6 CentOS 5.5的包,這對我很有用。

首先,我安裝用於創建RPM

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

一些東西而一些依賴

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 

抓起SRC RPM

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

而且最後

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 
0

您可能要添加EPEL回購:

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

然後啓用它在/etc/yum.repos.d/epel.repo:設置enabled=1

嘗試yum install gcc-c++ MySQL-python之後。