python ImportError: No module named redis

默认redis模块没有安装,安装方式很多种,下面只介绍一种最简单的:

[root@tom]# yum list | grep python | grep redis
python-redis.noarch                          2.0.0-1.el6                 @epel  
[root@tom]# yum install python-redis 
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package python-redis.noarch 0:2.0.0-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================
 Package                                          Arch                                       Version                                            Repository                                Size
===============================================================================================================================================================================================
Installing:
 python-redis                                     noarch                                     2.0.0-1.el6                                        epel                                      30 k

Transaction Summary
===============================================================================================================================================================================================
Install       1 Package(s)

Total download size: 30 k
Installed size: 116 k
Is this ok [y/N]: y
Downloading Packages:
python-redis-2.0.0-1.el6.noarch.rpm                                                                                                                                     |  30 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : python-redis-2.0.0-1.el6.noarch                                                                                                                                             1/1 
  Verifying  : python-redis-2.0.0-1.el6.noarch                                                                                                                                             1/1 

Installed:
  python-redis.noarch 0:2.0.0-1.el6                                                                                                                                                            

Complete!

redis模块可以使用了。

[root@tom]# ptyhon
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import redis
>>> r = redis.Redis(host='localhost',port=6479)
>>> r.get('hello')
>>> world

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值