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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With