为什么redispy没有geo扩展?

2024-06-16 10:06:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我通过pip安装了redis-py2.10.5。它安装没有错误。但是,我无法访问与地理相关的功能。在

In [1]: import redis

In [2]: r = redis.StrictRedis(host='localhost', port=6379, db=0)

In [3]: r.set('foo', 'bar')
Out[3]: True

In [4]: r.geoadd('Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-4e252ecb84dd> in <module>()
----> 1 r.geoadd('Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669')

AttributeError: 'StrictRedis' object has no attribute 'geoadd'

我哪里出错了?在


Tags: pipinimport功能redislocalhosthostport
2条回答

r.execute_命令('Sicily 13.361389 38.115556“巴勒莫”15.087269 37.502669')

成功了。在

官方github repo中存在一个开放问题:'StrictRedis' object has no object called 'geoadd'

根据问题注释,您有两个选择:

You can either use the fork mentioned in that issue (preferred) or pip install git+https://github.com/andymccurdy/redis-py.git.

相关问题 更多 >