pip conda 国内镜像源 添加与删除

当我们在国内时,pip或conda默认源的速度可能很慢,导致下载失败,于是整理了一些国内镜像源。

 

pip国内源

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

中国科技大学         https://pypi.mirrors.ustc.edu.cn/simple/ 
豆瓣(douban)         http://pypi.douban.com/simple/ 
清华大学                https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学  http://pypi.mirrors.ustc.edu.cn/simple/

 

使用方法为加 -i 加 url,如下(以安装sklearn为例): 

 pip install -U scikit-learn -i http://pypi.douban.com/simple 

 

有时会报错,说

 The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with ‘–trusted-host pypi.douban.com‘.
 

 

此时请按照提示输入如下命令:

pip install -U scikit-learn -i http://pypi.douban.com/simple –trusted-host pypi.douban.com

 

如果是使用conda来安装, 执行这两条命令,可以将国内镜像源加入config文件

conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config –set show_channel_urls yes

 

 然后再执行即可

conda install scikit-learn

 

二、但有时候你添加了国内镜像源之后又出国了,默认的源的速度比清华的快,你想把国内镜像源删除,你可以这样做。先查看channels里是否有清华镜像

conda config –get channels 

如果有,把它移除

conda config –remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

 

参考 :

https://www.cnblogs.com/sunnydou/p/5801760.html

https://blog.csdn.net/qq_23141851/article/details/81436795

https://blog.csdn.net/tangwenbo124/article/details/74784268

 

希望对你有帮助。

 

 

 

 

标签