mac osx下安装redis-python客户端

1、安装redis服务端

通过homebrew安装redis-server,命令行:

brew install redis

如果你没有安装homebrew,可以照着下面的命令行分别安装xcode命令行工具和homebrew,安装完redis-server后,在命令行直接运行redis-server命令,即可在本地启动redis的服务端: 

xcode-select --install
ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2、安装redis的python客户端

如果需要在python中导入和使用redis,需要安装redis的python客户端。下面依次是安装easy_install、redis的命令行,逐行执行,即可完成安装:

curl -O http://python-distribute.org/distribute_setup.py 
sudo python distribute_setup.py
sudo easy_install redis

3、redis验证,命令行中先运行redis-server,打开服务端后,就可以运行下面的python程序,开始使用pyredis了

#!/bin/python
import redis
conn = redis.Redis()
conn.hset('jack', 'sex', 'm')
conn.hset('jack', 'score', 90)
print conn.hgetall('jack')
原文地址:https://www.cnblogs.com/jacksonshi/p/5842115.html