解密conda channels 您所在的位置:网站首页 downloadingpackages是什么意思 解密conda channels

解密conda channels

2024-01-25 19:23| 来源: 网络整理| 查看: 265

欢迎关注”生信修炼手册”!

channels是conda下载包的镜像网站,通过如下命令可以查看已有的channels

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/

每个url对应的是不同操作系统平台的文件夹

在操作系统对应的目录下,是具体的安装包,后缀为tar.bz2

>https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/

在这些安装包中,有一个比较特殊repodata.json, 存储了该目录下包含的所有包的名称,依赖,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*"       ],

在安装包的时候,conda会依次遍历所有的channnels,通过repodata来查找该channel是否包含需要下载的packages,  一个基本的安装过程如下

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

对于某些不能用的镜像,会在下载repodata.json时失效,出现如下所示的报错

conda create -n myenv ggtree Collecting package metadata (current_repodata.json): failed CondaHTTPError: HTTP 000 CONNECTION FAILED for url  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.",),)

此时我们就需要确认下该镜像是失效了,还是因为网络原因,如果失效的话,就考虑删除这个镜像。

当网络波动时,会出现下载失败的情况,报错如下

CondaHTTPError: HTTP 000 CONNECTION FAILED for url 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.

此时镜像本身是没问题的,就是下载速度慢,导致下载失败,只需要多试几次即可。

对于channels而言,我们需要学会新增和删除,对应的操作如下

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子命令的本质是在操作.condarc这个配置文件,所以我们直接在这个配置文件里进行修改也是可以的,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

修改镜像的使用场景有以下两种,第一种是使用国内镜像,提高下载速度,第二种是为了下载特定镜像才包含的packages。镜像的修改非常简单,关键是要理解镜像的本质。

·end·

—如果喜欢,快分享给你的朋友们吧—

原创不易,欢迎收藏,点赞,转发!生信知识浩瀚如海,在生信学习的道路上,让我们一起并肩作战!

本公众号深耕耘生信领域多年,具有丰富的数据分析经验,致力于提供真正有价值的数据分析服务,擅长个性化分析,欢迎有需要的老师和同学前来咨询。

  更多精彩

KEGG数据库,除了pathway你还知道哪些

全网最完整的circos中文教程

DNA甲基化数据分析专题

突变检测数据分析专题

mRNA数据分析专题

lncRNA数据分析专题

circRNA数据分析专题

miRNA数据分析专题

单细胞转录组数据分析专题

chip_seq数据分析专题

Hi-C数据分析专题

HLA数据分析专题

TCGA肿瘤数据分析专题

基因组组装数据分析专题

CNV数据分析专题

GWAS数据分析专题

2018年推文合集

2019年推文合集

  写在最后

转发本文至朋友圈,后台私信截图即可加入生信交流群,和小伙伴一起学习交流。

扫描下方二维码,关注我们,解锁更多精彩内容!

一个只分享干货的

生信公众号



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有