CentOS 7 修改pip/pip3源

前言:由于网络有时不稳定的原因,使用pip/pip3下载会非常慢。如果使用国内镜像服务就完美的解决了下载速度慢的问题,但是Centos7默认的是国外原,所以整理出两个修改pip/pip3源的方法。

一、国内镜像列表

国内镜像列表:

http://pypi.douban.com/simple/ 豆瓣
http://mirrors.aliyun.com/pypi/simple/ 阿里
http://pypi.hustunique.com/simple/ 华中理工大学
http://pypi.sdutlinux.org/simple/ 山东理工大学
http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学
https://pypi.tuna.tsinghua.edu.cn/simple 清华

二、开始配置

有两个方法,方法一是一次性的,方法二是永久性的。

  1. 方法一

    后面的–trusted-host 是指设置为受信源,否则在安全性较高的连接下是连接不上的

    pip install --upgrade pip  -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
    
  2. 方法二

    进入根目录

    cd ~
    

    创建文件夹

    mkdir .pip
    

    进入目录

    cd .pip
    

    编辑文件pip.conf(会自动创建)

    vim pip.conf
    

    把下边的复制进去(我用的清华的源,如果想配置其他源至于要改下边的内容即可)

    [global]
    index-url=https://pypi.tuna.tsinghua.edu.cn/simple
    trusted-host = pypi.tuna.tsinghua.edu.cn
    
欢迎关注同名微信公众号:程序猿杂记

程序猿杂记

技术|交流|福利
发布了63 篇原创文章 · 获赞 87 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/weixin_44110998/article/details/104042358
今日推荐