zoukankan      html  css  js  c++  java
  • 替换国内yum源以及pip源

    因为一些原因,不论是网络还是啥啥啥的原因,国外的源访问时不时的很慢,这时候我们就可以将国外的源替换为国内源,提高下载速度。

    yum源替换

    环境:centos7(如果你的发行版本不是这个,此方法不保证能够成功)

    备份原有yum文件

    # mkdir yumrepo
    # mv /etc/yum.repos.d/* yumrepo/
    

    下载yum源配置文件

    yum源我主要使用的是163和阿里云的,配置文件的下载方式如下:

    1. 163 yum源
      # wget http://mirrors.163.com/.help/CentOS7-Base-163.repo -O /etc/yum.repos.d/CentOS7-Base-163.repo
      
    2. aliyun yum源
      # wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base-aliyun.repo 
      

    生成缓存

    生成缓存确认下载的源没有问题就可以使用了

    # yum clean all
    # yum makecache
    

    pip源替换

    pip源

    pip源我主要使用以下几个:

    1. 豆瓣:http://pypi.douban.com/simple/
    2. 清华:https://pypi.tuna.tsinghua.edu.cn/simple
    3. 阿里云: http://mirrors.aliyun.com/pypi/simple/
    4. 中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
    5. 中国科学技术大学: http://pypi.mirrors.ustc.edu.cn/simple/

    使用方法

    1. 临时使用
      如果只是临时使用,可以使用-i 加源的方式,如: pip install gevent -i https://pypi.tuna.tsinghua.edu.cn/simple
      注意:如果是http方式的pip源,默认是不安全的,需要增加--trusted-host选项,如pip install paramiko -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
    2. 永久更改
      如果希望永久更改,则需要修改配置文。
      • linux修改配置文
        修改 ~/.pip/pip.conf配置文,没有就创建一个,修改 index-url至你需要的pip源,内容如下:
        [global]
        index-url = https://pypi.tuna.tsinghua.edu.cn/simple
        
        http方式的配置文如下:
        [global]
        index-url = http://pypi.douban.com/simple
        [install]
        trusted-host=pypi.douban.com
        
      • windows修改配置文
        直接在user目录中创建一个pip目录,如:C:Userswatsonpip,新建文件pip.ini,内容如下:
        [global]
        index-url = https://pypi.tuna.tsinghua.edu.cn/simple
        
        其中index-url就是你选择的pip源
        http方式的配置文和linux下的配置文相同。
  • 相关阅读:
    反向代理实例
    nginx常用命令和配置
    nginx的安装
    Can Live View boot up images acquired from 64bit OS evidence?
    What is the behavior of lnk files?
    EnCase v7 search hits in compound files?
    How to search compound files
    iOS 8.3 JB ready
    Sunglasses
    现代福尔摩斯
  • 原文地址:https://www.cnblogs.com/cdinc/p/8966769.html
Copyright © 2011-2022 走看看