mac下python与redis结合
来源:互联网 发布:条码软件label matrix 编辑:程序博客网 时间:2024/06/05 06:48
开发环境 mac os
python版本 Python 2.7.6
redis版本 2.8.17
mac上安装软件比较方便,和yum和apt-get类似,使用brew install 可以解决大部分的工作
安装homebrew可以参照教程Homebrew | Mac 开发配置手册
安装后,使用brew install 命令安装所需的软件
redis 目录为 /usr/local/Cellar/redis/2.8.17/bin,在bin中使用
./redis-server 启动服务器
./redis-cli 启动客户端本文的重点就是这里了,默认版本的python不支持redis,出错如下
nyandeMacBook-Pro:~ nyan$ pythonPython 2.7.6 (default, Sep 9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import redisTraceback (most recent call last): File "<stdin>", line 1, in <module>ImportError: No module named redis
表示为安装python的redis支持,网上各种复制粘贴乱的不行,还是找到了源地址,andymccurdy/redis-py
这里用到了redis-py,下载后使用
sudo python setup.py install
输入密码后,正常安装
nyandeMacBook-Pro:redis-py-master nyan$ sudo python setup.py installPassword:running installChecking .pth file support in /Library/Python/2.7/site-packages//usr/bin/python -E -c passTEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth filesrunning bdist_eggrunning egg_infocreating redis.egg-infowriting redis.egg-info/PKG-INFOwriting top-level names to redis.egg-info/top_level.txtwriting dependency_links to redis.egg-info/dependency_links.txtwriting manifest file 'redis.egg-info/SOURCES.txt'reading manifest file 'redis.egg-info/SOURCES.txt'reading manifest template 'MANIFEST.in'warning: no previously-included files found matching '__pycache__'warning: no previously-included files matching '*.pyc' found under directory 'tests'writing manifest file 'redis.egg-info/SOURCES.txt'installing library code to build/bdist.macosx-10.10-intel/eggrunning install_librunning build_pycreating buildcreating build/libcreating build/lib/rediscopying redis/__init__.py -> build/lib/rediscopying redis/_compat.py -> build/lib/rediscopying redis/client.py -> build/lib/rediscopying redis/connection.py -> build/lib/rediscopying redis/exceptions.py -> build/lib/rediscopying redis/lock.py -> build/lib/rediscopying redis/sentinel.py -> build/lib/rediscopying redis/utils.py -> build/lib/rediscreating build/bdist.macosx-10.10-intelcreating build/bdist.macosx-10.10-intel/eggcreating build/bdist.macosx-10.10-intel/egg/rediscopying build/lib/redis/__init__.py -> build/bdist.macosx-10.10-intel/egg/rediscopying build/lib/redis/_compat.py -> build/bdist.macosx-10.10-intel/egg/rediscopying build/lib/redis/client.py -> build/bdist.macosx-10.10-intel/egg/rediscopying build/lib/redis/connection.py -> build/bdist.macosx-10.10-intel/egg/rediscopying build/lib/redis/exceptions.py -> build/bdist.macosx-10.10-intel/egg/rediscopying build/lib/redis/lock.py -> build/bdist.macosx-10.10-intel/egg/rediscopying build/lib/redis/sentinel.py -> build/bdist.macosx-10.10-intel/egg/rediscopying build/lib/redis/utils.py -> build/bdist.macosx-10.10-intel/egg/redisbyte-compiling build/bdist.macosx-10.10-intel/egg/redis/__init__.py to __init__.pycbyte-compiling build/bdist.macosx-10.10-intel/egg/redis/_compat.py to _compat.pycbyte-compiling build/bdist.macosx-10.10-intel/egg/redis/client.py to client.pycbyte-compiling build/bdist.macosx-10.10-intel/egg/redis/connection.py to connection.pycbyte-compiling build/bdist.macosx-10.10-intel/egg/redis/exceptions.py to exceptions.pycbyte-compiling build/bdist.macosx-10.10-intel/egg/redis/lock.py to lock.pycbyte-compiling build/bdist.macosx-10.10-intel/egg/redis/sentinel.py to sentinel.pycbyte-compiling build/bdist.macosx-10.10-intel/egg/redis/utils.py to utils.pyccreating build/bdist.macosx-10.10-intel/egg/EGG-INFOcopying redis.egg-info/PKG-INFO -> build/bdist.macosx-10.10-intel/egg/EGG-INFOcopying redis.egg-info/SOURCES.txt -> build/bdist.macosx-10.10-intel/egg/EGG-INFOcopying redis.egg-info/dependency_links.txt -> build/bdist.macosx-10.10-intel/egg/EGG-INFOcopying redis.egg-info/top_level.txt -> build/bdist.macosx-10.10-intel/egg/EGG-INFOzip_safe flag not set; analyzing archive contents...creating distcreating 'dist/redis-2.10.3-py2.7.egg' and adding 'build/bdist.macosx-10.10-intel/egg' to itremoving 'build/bdist.macosx-10.10-intel/egg' (and everything under it)Processing redis-2.10.3-py2.7.eggCopying redis-2.10.3-py2.7.egg to /Library/Python/2.7/site-packagesAdding redis 2.10.3 to easy-install.pth fileInstalled /Library/Python/2.7/site-packages/redis-2.10.3-py2.7.eggProcessing dependencies for redis==2.10.3Finished processing dependencies for redis==2.10.3
安装完成后,可以正常使用
nyandeMacBook-Pro:redis-py-master nyan$ pythonPython 2.7.6 (default, Sep 9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import redis>>> r = redis.Redis(host='localhost', port=6379, db=0)>>> r.set('foo', 'bar')True>>> r.get('foo')'bar'>>> exit()
0 0
- mac下python与redis结合
- 【redis】mac下 redis安装与测试
- mac下,redis的安装与配置
- mac下,redis的安装与配置
- mac下redis的安装与配置
- mac下,redis的安装与配置
- redis mac下安装与启动
- mac下,redis的安装与配置
- mac下的redis安装与配置
- mac下redis 安装与调用
- ubuntu下eclipse与python,mysql结合
- Redis与Mysql结合
- Redis与MySql结合
- redis与MySQL结合
- Mac下安装redis
- Mac下安装redis
- mac 下安装redis
- mac下使用redis
- Word2007插入目录、更新目录后大纲乱掉和无法保存大纲的解决办法
- 入门经典题
- 黑马程序员--IOS-学习笔记-UI02
- Python中Cookie的处理(二)cookielib库
- AiX--Ipcs 资源
- mac下python与redis结合
- 搭建第一个struts2框架web程序
- HHVM 是如何提升 PHP 性能的?
- Web系统大规模并发——电商秒杀与抢购
- 我在项目中Springmvc异常日志处理(二) ps:如何有更好的方法,请写到评论中多多交流,谢谢!
- 详解Oracle几种性能调优方法
- 回撤换行
- 嵌入式 死锁&活锁含义
- 企业收购并购