ImportError: No module named redis

73,378

Solution 1

To install redis-py, simply:

$ sudo pip install redis

or alternatively (you really should be using pip though):

$ sudo easy_install redis

or from source:

$ sudo python setup.py install

Getting Started

>>> import redis
>>> r = redis.StrictRedis(host='localhost', port=6379, db=0)
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
'bar'

Details:https://pypi.python.org/pypi/redis

Solution 2

I was facing the same issue and this is how I resolved it. Check if you use a virtualenv named dev then don't do

sudo pip install redis 

but just

pip install redis

This will install the redis package in your own virtualenv instead of your "complete" system, and this time your redis package will be found from your code.

Solution 3

I had the same issue, the error was that the default pip was 'pip3', and the redis package was installed under python3 packages.

This is not a redis specific issue, but if this is the case for you, try running:

sudo pip2 install redis
Share:
73,378
Mona Jalal
Author by

Mona Jalal

contact me at [email protected] I am a 5th-year computer science Ph.D. Candidate at Boston University advised by Professor Vijaya Kolachalama in computer vision as the area of study. Currently, I am working on my proposal exam and thesis on the use of efficient computer vision and deep learning for cancer detection in H&E stained digital pathology images.

Updated on October 04, 2020

Comments

  • Mona Jalal
    Mona Jalal over 3 years

    I have installed redis using sudo apt-get install redis-server command but I am receiving this error when I run my Python program: ImportError: No module named redis

    Any idea what's going wrong or if I should install any other package as well? I am using Ubuntu 13.04 and I have Python 2.7.