当前位置 博文首页 > 一劳永逸彻底解决pip install慢的办法

    一劳永逸彻底解决pip install慢的办法

    作者:autofelix 时间:2021-05-27 17:49

    前言

    Python 的一大优点就是丰富的类库,所以我们经常会用 pip 来安装各种库,所以对于Python开发用户来讲,PIP安装软件包是家常便饭。但国外的源下载速度实在太慢,浪费时间。而且经常出现下载后安装出错问题。所以把PIP安装源替换成国内镜像,可以大幅提升下载速度,还可以提高安装成功率。

    一、将pip修改为pip国内源即可 

    pip和很多的包管理工具一样,是从国外源下载的。因此速度会比较慢,甚至会安装不了

    清华:https://pypi.tuna.tsinghua.edu.cn/simple

    阿里云:https://mirrors.aliyun.com/pypi/simple/

    中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/

    二、临时修改

    可以在使用pip的时候加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple

    pip install pycrytodome -i https://pypi.tuna.tsinghua.edu.cn/simple

    这样就会从清华镜像库去安装pycrytodome库 

    三、永久修改

    liunx系统

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

    window系统

    在user目录中创建一个pip目录,如:C:\Users\pip,新建文件pip.ini,添加一下内容

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

    总结

    js
    下一篇:没有了