更改pip源
为了解决使用pip安装python相关包速度慢的问题,可以更改pip下载源为国内源。
常见的源网址有:
清华:https://pypi.tuna.tsinghua.edu.cn/simple
中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
其他的源网址可以搜索查找到。
如何修改pip源
在对应的环境中(无论是cmd(windows os),还是在anaconda自己创建的虚拟环境,或者其他环境都可以),输入指令
pip config set global.index-url url(相应的源网址)
例如将源修改为清华源:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
如果得到如下的结果则表明修改成功。
修改下载时间限制
使用pip指令安装库时,添加指令--default-timeout=xxxx
即可,其中xxxx为自定义的时间值,例如
pip install numpy --default-timeout=10000
(补充)使用conda install指令时,若要自定义超时时间,则按如下步骤
①查看配置信息
conda config --show
②修改remote_connect_timeout_secs和remote_read_timeout_secs属性(连接超时时间和读取超时时间)
conda config --set remote_connect_timeout_secs xxx
conda config --set remote_read_timeout_secs xxx
其中xxx为数字,如111、222、333等。