![](/img/trans.png)
[英]Redis-Py AttributeError: 'int' object has no attribute 'items'
[英]redis-py AttributeError: 'module' object has no attribute
我在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的東西......
您正在命名一個正在處理redis.py
的模塊,Python正在導入而不是真正的redis
模塊。 不要這樣做,或者更改sys.path
以確保當前工作目錄在搜索目錄列表中是最后一個而不是第一個。
我在龍卷風中有這個錯誤,這是因為我在python 2.7上安裝redis並安裝在python3中,我從python2.7卸載redis並在python3中重新安裝並解決問題!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.