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 清华

二、Centos配置过程

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

  1. 方法一

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

    以安装pandas为例

    pip install pandas -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
    

二、Windows配置过程

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

  1. 方法一

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

    以安装pandas为例

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

    在windows文件管理器中,输入 %APPDATA%,然后回车,接下来会进入一个新的路径
    在这里插入图片描述
    在该目录下新建pip文件夹,然后到pip文件夹里面去新建个pip.ini文件
    在这里插入图片描述

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

    [global]
    index-url=https://pypi.tuna.tsinghua.edu.cn/simple
    trusted-host = pypi.tuna.tsinghua.edu.cn
    
posted @ 2020-01-19 20:02  程序猿杂记  阅读(684)  评论(0)    收藏  举报