Anaconda 國內鏡像源 添加與刪除


當我們在國內時,pipconda默認源的速度可能很慢,導致下載失敗,於是整理了一些國內鏡像源。

1.國內鏡像源

阿里雲           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/

2.顯示所有channel

conda config --show             # 顯示出所有conda的config信息。
conda config --get channels     # 查看當前配置狀態
conda config --show channels    # 查看當前配置狀態(?我的筆記本不可以用)
conda config --show-sources     # 查看配置文件位置

3.移除channel

conda config --remove channels  https://pypi.mirrors.ustc.edu.cn/simple/

4.添加可用的channel

4.1 pip安裝

使用方法爲加-iurl,如下(以安裝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
4.2conda安裝

如果是使用conda來安裝, 執行這兩條命令,可以將國內鏡像源加入config文件

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes 
# 從channel中安裝包時顯示channel的url,這樣就可以知道包的安裝來源了。

然後再執行即可

conda install scikit-learn

參考:

https://blog.csdn.net/qq_41204464/article/details/86539942

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章