在CentOS 7.7 x86_64上为python 2.7.5安装pip的靠谱方法

我的虚拟机是CentOS 7.7 x86_64系统,对应的python默认版本是2.7.5,但是没有安装pip,不方便安装第三方模块。

我想为为它安装pip工具,发现现有的安装方法都行不通了,比如先安装easy_install,再通过easy_install安装pip的方法


echo '=======install setuptools ============'
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py
 
echo '=======install pip =========='
easy_install-2.7 pip
pip -V

它会报下面的错误

下面是正常的安装方法
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python get-pip.py
pip -V

 

如果直接使用官方镜像源,通常会报“网络不可达等错误,pip Failed to establish a new connection: [Errno 101] 网络不可达”

更改官方源镜像

pip --default-timeout=100 install numpy -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

pip --default-timeout=100 install pillow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

pip国内源

阿里云镜像:https://mirrors.aliyun.com/pypi/simple/
清华大学镜像:https://pypi.tuna.tsinghua.edu.cn/simple/
腾讯镜像:https://mirrors.cloud.tencent.com/pypi/simple
豆瓣镜像:https://pypi.doubanio.com/simple/
中科大镜像:https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

全局设置方法
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple

单次设置源方法
pip install markdown -i https://mirrors.aliyun.com/pypi/simple

参考文献
[1].https://zhuanlan.zhihu.com/p/378769376

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值