I installed redis with pip, and in Python2 interpreter, it's ok to import redis
But, in Python3 interpreter, I got ImportError: No module named 'redis'
So why does this happen?
I installed redis with pip, and in Python2 interpreter, it's ok to import redis
But, in Python3 interpreter, I got ImportError: No module named 'redis'
So why does this happen?
When you install redis by 'sudo pip install redis', actually you install redis driver to path which python2.x uses (take OS X for example) :
/Library/Python/2.7/site-packages/redis
If install with python3, it will be installed to path :
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/redis-2.10.5-py3.5.egg
It's different if you use other os, but that's why you can import redis using python3.
If you want to use redis with python3, there are two ways to do this:
1) build redis from source:
https://github.com/andymccurdy/redis-py.git
cd redis-py
python3 setup.py install
2) install pip for python3, you can refer to here.