CentOS7 安装pip/pip3


1.python2安装pip

yum -y install epel-release               (安装epel扩展源)
yum -y install python-pip                                (安装pip)

升级pip

pip install --upgrade pip

2.python3安装pip

python3中自带pip3,因此只需要添加pip3的软链接即可

ln -s /usr/local/python3.6/bin/pip3    /usr/bin/pip3

3.修改pip3源

在当前用户目录下创建  .pip  目录,进入目录,创建pip.conf,添加国内源

mkdir ~/.pip
vim ~/.pip/pip.conf
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple/ [install] trusted-host=pypi.tuna.tsinghua.edu.cn
国内其他源:

 阿里云 http://mirrors.aliyun.com/pypi/simple/
  中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
  豆瓣 http://pypi.douban.com/simple
  Python官方 https://pypi.python.org/simple/
  v2ex http://pypi.v2ex.com/simple/
  中国科学院 http://pypi.mirrors.opencas.cn/simple/
  清华大学 https://pypi.tuna.tsinghua.edu.cn/simpl

或者临时修改pip源

pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
原文地址:https://www.cnblogs.com/haoee/p/14842547.html