Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use redis-py has error #12

Open
orangle opened this issue Jan 31, 2019 · 2 comments
Open

Use redis-py has error #12

orangle opened this issue Jan 31, 2019 · 2 comments

Comments

@orangle
Copy link

orangle commented Jan 31, 2019

I used pip install -r requirements.txt to install python packages, the default redis-py is 3.0.1.
when i start python redis_monitor.py, some error happened

2019-01-31 13:17:39.020112
Traceback (most recent call last):
  File "redis_monitor.py", line 88, in run
    self.LogInfo(redis_info, current_time, self.last)
  File "redis_monitor.py", line 185, in LogInfo
    expired, evicted, hit_rate, commands, used_memory, peak_memory)
  File "/usr/local/redis-monitor/src/dataprovider/redisprovider.py", line 33, in save_keys_Info
    self.conn.zadd(server +':'+ rediskey, score, data)
  File "/usr/lib/python2.7/site-packages/redis/client.py", line 2263, in zadd
    for pair in iteritems(mapping):
  File "/usr/lib/python2.7/site-packages/redis/_compat.py", line 94, in iteritems
    return x.iteritems()
AttributeError: 'int' object has no attribute 'iteritems'

then I found redis-py 3.xx had some changes https://github.com/andymccurdy/redis-py#mset-msetnx-and-zadd

def mset(self, mapping):
def msetnx(self, mapping):
def zadd(self, name, mapping, nx=False, xx=False, ch=False, incr=False):

so, we need do some compatible or prompt user to install redis-py 2.x version?

@LittlePeng
Copy link
Owner

you can try one of the following

  1. fix requirements.txt with special version redis-py 2.x
  2. replace zadd(key, field, val) -> zadd(key, {field:val}) in redisprovider.py

PR welcome

@miaocbin
Copy link

pip install -r requirements.txt

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting python-dateutil
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
|████████████████████████████████| 227 kB 21.6 MB/s
Collecting redis
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/f0/05/1fc7feedc19c123e7a95cfc9e7892eb6cdd2e5df4e9e8af6384349c1cc3d/redis-3.4.1-py2.py3-none-any.whl (71 kB)
|████████████████████████████████| 71 kB 42.2 MB/s
Collecting tornado
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/e6/78/6e7b5af12c12bdf38ca9bfe863fcaf53dc10430a312d0324e76c1e5ca426/tornado-5.1.1.tar.gz (516 kB)
|████████████████████████████████| 516 kB 32.5 MB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zaKVA7/tornado/setup.py'"'"'; file='"'"'/tmp/pip-install-zaKVA7/tornado/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-zaKVA7/tornado/pip-egg-info
cwd: /tmp/pip-install-zaKVA7/tornado/
Complete output (17 lines):
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-zaKVA7/tornado/setup.py", line 195, in
**kwargs
File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 269, in init
_Distribution.init(self,attrs)
File "/usr/lib64/python2.7/distutils/dist.py", line 287, in init
self.finalize_options()
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 302, in finalize_options
ep.load()(self, ep.name, value)
File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2341, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2351, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'check_specifier'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants