1、pip 安装时
问题:
在cmd或anaconda prompt 中用 pip 安装时,速度慢,而且总是超时中断安装(Read timed out)
一般安装:pip install jupyterlab 网络不好时总是超时中断
解决办法:
利用镜像安装:pip install jupyterlab -i 网址
(下载速度可以提高几十倍)
pip install jupyterlab -i https://pypi.douban.com/simple
pipy国内镜像目前有:
https://pypi.douban.com/ 豆瓣
https://pypi.hustunique.com/ 华中理工大学
https://pypi.sdutlinux.org/ 山东理工大学
https://pypi.mirrors.ustc.edu.cn/ 中国科学技术大学
比如:下载matplotlib库
pip install matplotlib -i https://pypi.douban.com/simple
同样的安装同样的东西,下载速度的对比:一个是409kB/s 一个是3.3MB/s
2、conda 安装时
问题:
anaconda prompt 中用 conda 安装第三方库时,速度慢,或因超时而中断安装。
解决方法:
conda安装时可以使用清华镜像,运行下面的命令可以把conda的下载地址设置为清华镜像地址(只设置一次,以后就可以都从此地址下载了)
Anaconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载。
TUNA 还提供了 Anaconda 仓库的镜像,运行以下命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
像下图一样在anaconda prompt运行命令,即可添加 Anaconda Python 免费仓库(即清华镜像)。
运行 conda install numpy
测试一下吧。
参考网址:
Tsinghua Open Source Mirrormirror.tuna.tsinghua.edu.cn