ubuntu中pip安装redis-py及pip的使用

安装redis-py的前提是已经将redis成功安装,redis安装过程请看博文

  ubuntu14安装redis

1.安装pip

sudo apt-get install python-pip

 

2.使用pip安装redis-py

sudo pip install redis

 

3.此时便可以在python中使用redis了

 1 pc@pc-virtual-machine:~/Desktop$ python
 2 Python 2.7.6 (default, Jun 22 2015, 18:00:18) 
 3 [GCC 4.8.2] on linux2
 4 Type "help", "copyright", "credits" or "license" for more information.
 5 >>> import redis
 6 >>> r = redis.Redis(host = "localhost")
 7 >>> r.set("name","good night");
 8 True
 9 >>> r.get("name")
10 'good night'
11 >>> 

 

4.pip的使用详解

4.1pip安装包

  pip install SomePackage

      [...]
  Successfully installed SomePackage
 
4.2 pip检查哪些包需要升级
  pip list --outdate
 
4.3 pip升级包
  pip install --upgrade SomePackage
 
4.4 pip卸载包
  pip uninstall SomePackage
  Uninstalling SomePackage:
    /my/env/lib/pythonx.x/site-packages/somepackage
  Proceed (y/n)? y
  Successfully uninstalled SomePackage
 
4.5 pip帮助
  

pip --help

Usage:
pip <command> [options]

Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
help Show help for commands.

 

 

 4.6 ubuntu下会经常使用pip安装一些包,默认使用国外的镜像源,下载比较慢。可以将镜像源设置成国内的。国内有清华、阿里、中科大。

临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。
 
长久使用,修改配置文件
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
[global]  
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

清华大学的pip源,它是官网pypi的镜像,每隔5分钟同步一次

 

 

转载于:https://www.cnblogs.com/zhaopengcheng/p/5225737.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值