Replace domestic yum source and pip source

For some reasons, whether it is the network or something, the access to foreign sources is very slow from time to time. At this time, we can replace the foreign sources with domestic sources to improve the download speed.

yum source replacement

Environment: centos7 (if your distribution is not this, this method is not guaranteed to succeed)

Backup the original yum file

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

Download the yum source configuration file

The yum source I mainly use is 163 and Alibaba Cloud. The download method of the configuration file is as follows:

  1. 163 yum source

    # wget http://mirrors.163.com/.help/CentOS7-Base-163.repo -O /etc/yum.repos.d/CentOS7-Base-163.repo
  2. aliyun yum source

    # wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base-aliyun.repo 

    Generate cache

    Generate a cache to confirm that the downloaded source can be used without problems

    # yum clean all
    # yum makecache

    pip source replacement

    pip source

    I mainly use the following pip sources:
  3. Douban: http://pypi.douban.com/simple/
  4. Tsinghua: https://pypi.tuna.tsinghua.edu.cn/simple

Instructions

  1. Temporary use For
    temporary use, you can use -i to add source, such as: pip install gevent -i https://pypi.tuna.tsinghua.edu.cn/simple
  2. Permanent changes
    If you want to make permanent changes, you need to modify the configuration file.
    • linux modify the configuration file
      Modify the ~/.pip/pip.conf configuration file, create one if not, modify the index-url to the pip source you need, the content is as follows:

      [global]
      index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    • Modifying the configuration file in windows
      Create a pip directory directly in the user directory, such as: C:\Users\watson\pip, and create a new file pip.ini with the following contents:

      [global]
      index-url = https://pypi.tuna.tsinghua.edu.cn/simple

      where index-url is the pip source of your choice

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325037221&siteId=291194637