溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么在conda中設(shè)置channel鏡像

發(fā)布時間:2021-05-17 15:11:44 來源:億速云 閱讀:1297 作者:Leah 欄目:開發(fā)技術(shù)

這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)怎么在conda中設(shè)置channel鏡像,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

1 顯示所有channel

首先,conda config --show能夠顯示出所有conda的config信息。

如果我們只想看channels的信息,輸入conda config --show channels即可,如下:

(base) C:\Users\dehen>conda config --show channels
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - defaults

現(xiàn)在我們有兩個源,一個清華鏡像,一個defauls默認(rèn)下載源。

然而這個清華源已經(jīng)不能用了,我在下載opencv的時候,輸入:conda install opencv,但是報錯:

(base) C:\Users\dehen>conda install opencv
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64/repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
ConnectionError(ReadTimeoutError("HTTPSConnectionPool(host='mirrors.tuna.tsinghua.edu.cn', port=443): Read timed out."))

所以我打算刪除這個源。

2 移除清華鏡像

輸入:conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
這個命令是為了移除之前conda config --show channels顯示的清華源。

(base) C:\Users\dehen>conda config --remove channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

(base) C:\Users\dehen>conda config --show channels
channels:
  - defaults

(base) C:\Users\dehen>

這時候再運行conda config --show channels會發(fā)現(xiàn)清華源已經(jīng)被刪除了

3 添加可用的清華源

參考[4],我發(fā)現(xiàn)自己之前安裝的清華源的地址https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ 是清華維護(hù)的conda三方源之一conda-forge的鏡像,,,此外清華還有很多可用的源。

所以我根據(jù)官網(wǎng)指示進(jìn)行了添加:

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

conda config --set show_channel_urls yes的意思是從channel中安裝包時顯示channel的url,這樣就可以知道包的安裝來源了。

4 下載opencv

在添加好這個源(channel)之后,我重新運行conda install opencv,果然能夠成功下載?。。?/p>

但是中間竟然是自動安裝,在安裝前的確認(rèn)[Y/N]的時候,conda直接跳過了,默認(rèn)是Y。。。

這讓我非常難受,所以我運行了:

conda config --set always_yes false

(這里的意思是安裝確認(rèn)中,不默認(rèn)yes,而是由我來決定)

5 一些其他的conda指令

conda install <包名> 安裝指定包
conda remove <包名> 移除指定包
conda update <包名> 更新指定包

上述就是小編為大家分享的怎么在conda中設(shè)置channel鏡像了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI