conda config --show channels
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- defaults>https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
每個(gè)url對應的是不同操作系統平臺的文件夾
在操作系統對應的目錄下,是具體的安裝包,后綴為tar.bz2
>https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
在這些安裝包中,有一個(gè)比較特殊repodata.json, 存儲了該目錄下包含的所有包的名稱(chēng),依賴(lài),md5等信息
部分內容如下
{
"info": {
"arch": "x86_64",
"platform": "linux",
"subdir": "linux-64"
},
"packages": {
"_libgcc_mutex-0.1-free.tar.bz2": {
"build": "free",
"build_number": 0,
"date": "2019-07-01",
"depends": [],
"md5": "f7d7639c8485ae4701aeb6add534a774",
"name": "_libgcc_mutex",
"size": 3129,
"timestamp": 1562011672620,
"track_features": "free_channel_libgcc",
"version": "0.1"
},
"_license-1.1-py27_0.tar.bz2": {
"build": "py27_0",
"build_number": 0,
"date": "2013-03-01",
"depends": [
"python 2.7*"
],在安裝包的時(shí)候,conda會(huì )依次遍歷所有的channnels,通過(guò)repodata來(lái)查找該channel是否包含需要下載的packages, 一個(gè)基本的安裝過(guò)程如下
conda create -n myenv numpy
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /media/gsadmin/vd1/heguangliang/bcbio3/anaconda/envs/myenv
added / updated specs:
- numpy
The following packages will be downloaded:
package | build
---------------------------|-----------------
blas-1.0 | mkl 6 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
numpy-1.13.1 | py36_0 7.2 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
------------------------------------------------------------
Total: 7.2 MB
The following NEW packages will be INSTALLED:
blas anaconda/pkgs/free/linux-64::blas-1.0-mkl
certifi anaconda/pkgs/free/linux-64::certifi-2016.2.28-py36_0
mkl anaconda/pkgs/free/linux-64::mkl-2017.0.3-0
numpy anaconda/pkgs/free/linux-64::numpy-1.13.1-py36_0
openssl anaconda/pkgs/free/linux-64::openssl-1.0.2l-0
pip anaconda/pkgs/free/linux-64::pip-9.0.1-py36_1
python anaconda/pkgs/free/linux-64::python-3.6.2-0
readline anaconda/pkgs/free/linux-64::readline-6.2-2
setuptools anaconda/pkgs/free/linux-64::setuptools-36.4.0-py36_1
sqlite anaconda/pkgs/free/linux-64::sqlite-3.13.0-0
tk anaconda/pkgs/free/linux-64::tk-8.5.18-0
wheel anaconda/pkgs/free/linux-64::wheel-0.29.0-py36_0
xz anaconda/pkgs/free/linux-64::xz-5.2.3-0
zlib anaconda/pkgs/free/linux-64::zlib-1.2.11-0
Proceed ([y]/n)?
Downloading and Extracting Packages
numpy-1.13.1 | 7.2 MB | ################################################################################################################################# | 100%
blas-1.0 | 6 KB | ################################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate myenv
#
# To deactivate an active environment, use
#
# $ conda deactivate對于某些不能用的鏡像,會(huì )在下載repodata.json時(shí)失效,出現如下所示的報錯
conda create -n myenv ggtree
Collecting package metadata (current_repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64/current_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.",),)此時(shí)我們就需要確認下該鏡像是失效了,還是因為網(wǎng)絡(luò )原因,如果失效的話(huà),就考慮刪除這個(gè)鏡像。
當網(wǎng)絡(luò )波動(dòng)時(shí),會(huì )出現下載失敗的情況,報錯如下
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/mkl-2020.2-256.conda>
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.此時(shí)鏡像本身是沒(méi)問(wèn)題的,就是下載速度慢,導致下載失敗,只需要多試幾次即可。
對于channels而言,我們需要學(xué)會(huì )新增和刪除,對應的操作如下
1. 刪除
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/2. 增加
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/config子命令的本質(zhì)是在操作.condarc這個(gè)配置文件,所以我們直接在這個(gè)配置文件里進(jìn)行修改也是可以的,condarc的內容示例如下
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- defaults
ssl_verify: false
show_channel_urls: true修改鏡像的使用場(chǎng)景有以下兩種,第一種是使用國內鏡像,提高下載速度,第二種是為了下載特定鏡像才包含的packages。鏡像的修改非常簡(jiǎn)單,關(guān)鍵是要理解鏡像的本質(zhì)。
聯(lián)系客服