banner ad

Install Redis for Python in Windows

| May 13, 2013 | 0 Comments
0 Flares 0 Flares ×

Downloan redis 2.7.4. The python interface to the reids key-value store. The url:https://github.com/andymccurdy/redis-py
installation the redis for python.

  • to install redis-py: $sudo pip install redis
  • alternatively: $sudo easy_install reids
  • or from source: $sudo python setup.py intall

If you are windows user, put the redis package to $(python path)/lib and install with python setup.py install.
when you input ‘import redis’ and no syntaxerror. That’s mean reids is OK.

then start with redis:
when you start redis with python, you should start redis server, you can setup the redis in local, start redis-server. If your python run with ‘ConnectionError: Error 10061 connecting 127.0.0.1:6379’, that’s mean your redis server has problem.
OK, let’s run python with redis.

import redis
r = redis.StrictRedis(host = '127.0.0.1', port = 6379, db = 0);
r.set('name','kem')
print(r.get('name'))

result:kem

redis server:

python_redis

redis :

redis_python

 

Download PDF
0 Flares Twitter 0 Facebook 0 Google+ 0 Pin It Share 0 LinkedIn 0 Reddit 0 StumbleUpon 0 0 Flares ×

Tags: ,

Category: Database

About the Author ()

My name is John Link.I am 26 years old. My major is Computer science and technology. I am a junior programmer with Python.

Leave a Reply

Your email address will not be published. Required fields are marked *

0 Flares Twitter 0 Facebook 0 Google+ 0 Pin It Share 0 LinkedIn 0 Reddit 0 StumbleUpon 0 0 Flares ×