我遇到以下错误:
➜ 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
以下是一些线索:
➜ 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...
➜ 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...
答案 0 :(得分:2)
如果您使用名为dev
的virtualenv,那么就不要
sudo pip install redis
但只是
pip install redis
这将在您自己的virtualenv而不是“complet”系统中安装redis软件包。 这次你的redis软件包将在你的代码中找到。
答案 1 :(得分:0)
我确信OP可能已经过了这个但是对于仍然在这里的用户而言,其中一个可能的原因是你已经安装了python3并试图通过pip
而不是{{1}来安装软件包}}
pip3
应该对此进行排序。