美文网首页
pip 下载超时 镜像源配置

pip 下载超时 镜像源配置

作者: phantomvk | 来源:发表于2016-11-24 23:04 被阅读0次

    国内访问Python pip官方镜像源速度非常慢,matplotlib下载速度只有10KB/s,而且下载没一会儿还连接超时。浪费时间不止,几次下载没有一次成功过。

    最好的解决办法就是给pip增加国内镜像源。按照下面步骤设置好后,matplotlib下载有超百倍提升,从15KB/s提升到3.6MB/s。体积比较小的库下载速度实测满速。

    先拿Mac OSX来详细说,终端进入目录:

    $ cd ~/
    

    如果没有.pip这个文件夹,那么就手动新建这个文件夹

    $ mkdir .pip
    

    然后进入.pip,在文件夹内新建一个文件

    $ cd .pip
    $ touch pip.conf
    

    编辑 pip.conf 文件,写入阿里云镜像源

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

    同样可以选择豆瓣镜像源

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

    其他系统pip.conf保存位置

    Linux/Unix:

    ~/.pip/pip.conf
    

    Windows:

    %APPDATA%\pip\pip.ini
    %HOME%\pip\pip.ini
    C:\Documents and Settings\All Users\Application Data\PyPA\pip\pip.conf (For Windows XP)
    C:\ProgramData\PyPA\pip\pip.conf (For Windows 7)
    

    其他镜像源:

    1. 华中理工大学 http://pypi.hustunique.com/
    2. 山东理工大学 http://pypi.sdutlinux.org/
    3. 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/

    相关文章

      网友评论

          本文标题:pip 下载超时 镜像源配置

          本文链接:https://www.haomeiwen.com/subject/wodipttx.html