python找不到redis

标签 python redis

我遇到了以下错误:

➜  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...

最佳答案

如果你使用名为 dev 的 virtualenv 那么不要这样做

sudo pip install redis 

只是

pip install redis

这将在您自己的 virtualenv 而不是您的“完整”系统中安装 redis 包。 而这次将从您的代码中找到您的 redis 包。

关于python找不到redis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18810032/

相关文章:

node.js - 如何使用 node.js + redis 处理用户和套接字对

python - 使用 Celery 与 Gevent 进行实时、同步的外部 API 查询

python - 启动 rq-worker 时如何修复 'Error 111 connecting to localhost:6379. Connection refused'?

python - 带嵌套字典的 Pandas DataFrame

python - groupby 对象 pandas 的绝对值平均值

Python Newaxis 与 for 循环

node.js - Node JS Express 端口

python - 如何在 ssh 客户端而不是 ssh 服务器上显示 python/openCV 结果图像?

python - ROS:变压器总是空的

python - REDIS中key过期如何回调