Python cannot find redis

I encountered the following error:

➜ iPokeMon-Server git:(dev) sudo python server.py Password: Traceback (most recent call last): File "server.py", line 2, in <module> import redis ImportError: No module named redis 

Here are some tips:

 ➜ iPokeMon-Server git:(dev) sudo easy_install redis Searching for redis Best match: redis 2.8.0 Processing redis-2.8.0-py2.7.egg redis 2.8.0 is already the active version in easy-install.pth Using /Library/Python/2.7/site-packages/redis-2.8.0-py2.7.egg Processing dependencies for redis Finished processing dependencies for redis 

 ➜ iPokeMon-Server git:(dev) sudo pip install redis Requirement already satisfied (use --upgrade to upgrade): redis in /Library/Python/2.7/site-packages/redis-2.8.0-py2.7.egg Cleaning up... 

and for one below

 ➜ iPokeMon-Server git:(dev) pip install redis Requirement already satisfied (use --upgrade to upgrade): redis in /Library/Python/2.7/site-packages/redis-2.8.0-py2.7.egg Cleaning up... 
+4
source share
2 answers

If you are using virtualenv named dev then do not

 sudo pip install redis 

but just

 pip install redis 

this will install the redis package in your own virtualenv instead of your "complete" system. And this time, your redis package will be found from your code.

+2
source

I am sure that the OP may have passed this, but for users who are still landing here. One possible reason is that you installed python3 and are trying to install the package via pip instead of pip3 .

 pip3 install redis 

should sort it out.

0
source

Source: https://habr.com/ru/post/1502236/


All Articles