我在CentOS和Ubuntu上安装了redis-py。在尝试访问时,两者都出现相同的错误。
redis-py AttributeError: 'module' object has no attribute
如果我在与源代码相同的目录中使用Python提示符,这将有效:
>>> import redis
>>> r = redis.Redis(host='localhost', port=6379, db=0)
但如果我更改目录,它将会出现错误。
>>> 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__'
尝试使用.py
脚本总是会出现错误。有什么想法我做错了什么,以及如何修复它。可能是Python新手的问题...