12

I installed redis-py on CentOS and Ubuntu. On both I get the same error when trying to access it.

redis-py AttributeError: 'module' object has no attribute

If I use the python prompt in the same directory as the source this will work:

>>> import redis
>>> r = redis.Redis(host='localhost', port=6379, db=0)

but if I change directories it will give the error.

>>> import redis
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "redis.py", line 4, in <module>
    print redis.__version__
AttributeError: 'module' object has no attribute '__version__'

Trying with a .py script always gives the error. Any idea what I'm doing wrong, and how to fix it. Probably a newbie Python thing...

1
  • Could you give us more information on how you installed redis-py Commented Mar 26, 2013 at 23:43

2 Answers 2

42

You're naming a module you're working on redis.py and Python is importing that instead of the real redis module. Don't do that, or change sys.path to make sure the current working directory is last rather than first in the lists of directories to search.

Sign up to request clarification or add additional context in comments.

Comments

0

i have this error in tornado and it was because i install redis on python 2.7 and install in python3 too , i uninstall redis from python2.7 and re_install in python3 and solve the Problem!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.