zoukankan      html  css  js  c++  java
  • 更改PIP默认安装源

    1、个人安装环境

    1.1 Windows7x64 + Python 3.7.3

    1.2 Centos7 + 3.6.8

    2、默认安装源

    默认情况下使用的是pythonhosted.cn这个域名,这个就是python官方的域名,对应的网站是在国外。通常下载速度较慢,容易出错。

     3、更改国内安装源

    3.1 国内安装员列举

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

    3.2 速度测试

    使用Windows cmd进行ping测试,如

    C:Usersadmin>ping aliyun.com
    
    正在 Ping aliyun.com [2401:b180:1:50::f] 具有 32 字节的数据:
    来自 2401:b180:1:50::f 的回复: 时间=17ms
    来自 2401:b180:1:50::f 的回复: 时间=17ms
    来自 2401:b180:1:50::f 的回复: 时间=18ms
    来自 2401:b180:1:50::f 的回复: 时间=16ms
    
    2401:b180:1:50::f 的 Ping 统计信息:
        数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
    往返行程的估计时间(以毫秒为单位):
        最短 = 16ms,最长 = 18ms,平均 = 17ms
    
    C:Usersadmin>ping douban.com
    
    正在 Ping douban.com [154.8.131.172] 具有 32 字节的数据:
    来自 154.8.131.172 的回复: 字节=32 时间=29ms TTL=50
    来自 154.8.131.172 的回复: 字节=32 时间=28ms TTL=50
    来自 154.8.131.172 的回复: 字节=32 时间=27ms TTL=50
    来自 154.8.131.172 的回复: 字节=32 时间=28ms TTL=50
    
    154.8.131.172 的 Ping 统计信息:
        数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
    往返行程的估计时间(以毫秒为单位):
        最短 = 27ms,最长 = 29ms,平均 = 28ms
    
    C:Usersadmin>ping tuna.tsinghua.edu.cn
    
    正在 Ping tuna.tsinghua.edu.cn [2402:f000:1:416:101:6:6:172] 具有 32 字节的数据:
    来自 2402:f000:1:416:101:6:6:172 的回复: 时间=73ms
    来自 2402:f000:1:416:101:6:6:172 的回复: 时间=71ms
    来自 2402:f000:1:416:101:6:6:172 的回复: 时间=71ms
    来自 2402:f000:1:416:101:6:6:172 的回复: 时间=70ms
    
    2402:f000:1:416:101:6:6:172 的 Ping 统计信息:
        数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
    往返行程的估计时间(以毫秒为单位):
        最短 = 70ms,最长 = 73ms,平均 = 71ms

     很明显,我们这边使用阿里云速度较快!

    3.3 windows创建或修改pip.ini文件

    3.3.1 文件位置确认

    pip.ini位置为%USERPROFILE%pippip.ini(注意:以UTF-8无BOM编码格式保存),USERPROFILE位置使用set命令查看

    set

    运行结果: 

    USERPROFILE=C:Usersadmin
    VBOX_INSTALL_PATH=C:Program FilesOracleVirtualBox
    VS100COMNTOOLS=C:Program Files (x86)Microsoft Visual Studio 10.0Common7Tools
    windir=C:Windows
    windows_tracing_flags=3
    windows_tracing_logfile=C:BVTBinTestsinstallpackagecsilogfile.log 

     所以pip.int真实位置为C:Usersadminpippip.ini

    3.3.2 修改文件

    [global]
    timeout=300
    index-url=https://mirrors.aliyun.com/pypi/simple
    [install]
    trusted-host=aliyun.com
    

    3.4 Centos创建或修改pip.ini文件

    3.4.1 create file

    cd ~
    mkdir .pip
    cd .pip
    sudo gedit pip.conf
    

     3.4.2 copy and paste below texts

    [global]
    trusted-host=mirrors.douban.com
    index-url=https://pypi.douban.com/simple/
    

    4、安装测试

    以cmd中安装django进行测试:

    pip install django

    运行结果:

    Looking in indexes: https://mirrors.aliyun.com/pypi/simple
    Collecting django
      Downloading https://mirrors.aliyun.com/pypi/packages/c6/b7/63d23df1e311ca0d90f41352a9efe7389ba353df95deea5676652e615420/Django-3.0.3-py3-none-any.whl (7.5MB)
        100% |████████████████████████████████| 7.5MB 1.4MB/s
    Requirement already satisfied: pytz in c:programdataanaconda3libsite-packages (from django) (2018.9)
    Requirement already satisfied: asgiref~=3.2 in c:programdataanaconda3libsite-packages (from django) (3.2.3)
    Requirement already satisfied: sqlparse>=0.2.2 in c:programdataanaconda3libsite-packages (from django) (0.3.0)
    Installing collected packages: django
    Successfully installed django-3.0.3
    
  • 相关阅读:
    HTML元素解释
    Java命名规范
    HDU 1058 Humble Numbers(DP,数)
    HDU 2845 Beans(DP,最大不连续和)
    HDU 2830 Matrix Swapping II (DP,最大全1矩阵)
    HDU 2870 Largest Submatrix(DP)
    HDU 1421 搬寝室(DP)
    HDU 2844 Coins (组合背包)
    HDU 2577 How to Type(模拟)
    HDU 2159 FATE(二维完全背包)
  • 原文地址:https://www.cnblogs.com/hester/p/12317171.html
Copyright © 2011-2022 走看看