The `conda` or `conda-like` package and environment manager usage and practical

The conda or conda-like package and environment manager usage and practical

1. Version Differences : what are the differences between conda 、 anaconda 、 bioconda 、 miniconda ?

tutorial-conda-miniconda-anaconda在这里插入图片描述

conda : can download and install packages and all of its dependencies. The information on where to download and what the dependencies are for each packages are stored in a database called a “channel”

bioconda : a conda channel which contains names, locations, and dependencies of many bioinformatics tools.

miniconda : slimmed-down distribution version of Anaconda. It has all the components of the Anaconda distribution, except the 200+ pre-installed data science applications.

anaconda : open-source python distribution. It is purpose-built for such applications as machine learning, data science, and large-scale data processing. This distribution includes the core python language, along with more than 200 packages, and a package management tool.

2. install miniconda
2.1 download and install packages Miniconda3-py38_4.10.3-Linux-x86_64.sh
$ bash Miniconda3-py38_4.10.3-Linux-x86_64.sh

to make the installation take effect, you should close the current terminal and re-open it.

(base) [biocodee@localhost ~]$ conda --version 
conda 4.10.3

the conda has been installed correctly.

3. find packages

use command conda search

(base) [biocodee@localhost ~]$ conda search numpy
Loading channels: done
# Name                       Version           Build  Channel             
numpy                          1.9.3 py27_nomklhbee5d10_3  pkgs/main           
numpy                          1.9.3  py27h1b885b7_7  pkgs/main           
numpy                          1.9.3  py27h28100ab_5  pkgs/main           
...
(base) [biocodee@localhost ~]$ conda config --show channels
channels:
  - conda-forge
  - bioconda
  - defaults
(base) [biocodee@localhost ~]$ conda search samtools
Loading channels: done
# Name                       Version           Build  Channel             
samtools                      0.1.12               0  bioconda            
samtools                      0.1.12               1  bioconda            
samtools                      0.1.12               2  bioconda            
samtools                      0.1.13               0  bioconda           ... 
#	
(base) [biocodee@localhost ~]$ conda search samtools | tail -n1
samtools                        1.14      hb421002_0  bioconda    

4. conda environments :
  • A (mostly) self-contained directory with a set of compatible packages
  • Uses links to reduce disk space when possible
  • Linking is relative to packages!
  • No more conflicting dependencies between versions!
Conda environments – common commands
  • lists available environments
(base) [biocodee@localhost ~]$ conda info --envs
# conda environments:
#
base                  *  /home/biocodee/miniconda3

(base) [biocodee@localhost ~]$ conda env list
# conda environments:
#
base                  *  /home/biocodee/miniconda3

  • create/remove environments : can specify packages versions and mix/max versions
##############################################################################
###new env default path 
(base) [biocodee@localhost ~]$ conda create --name=myenv python=3.8 numpy 'pysam>=0.16'
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##

  environment location: /home/biocodee/miniconda3/envs/myenv

  added / updated specs:
    - numpy
    - pysam[version='>=0.16']
    - python=3.8


The following packages will be downloaded:
...
Proceed ([y]/n)? n


CondaSystemExit: Exiting.

(base) [biocodee@localhost ~]$ conda env list
# conda environments:
#
base                  *  /home/biocodee/miniconda3


#can remove envs using cmd following : 
$ conda env remove --name=myenv

###############################################################################
### module `venv`, specifying new env path
#Specifying a location for an environment

  • activates / deactivates an environment
$ command -v samtools
$ conda activate samtools
$ command -v samtools
/home/gcb2020/conda/envs/samtools/bin/samtools
$ conda deactivate
$ command -v samtools
#disable the automatic base activation
$ conda config --set auto_activate_base false
#check conda version
[biocodee@localhost ~]$ conda --version 
conda 4.10.3
#activate conda
[biocodee@localhost ~]$ conda activate
#deactive conda
(base) [biocodee@localhost ~]$ conda deactivate
[biocodee@localhost ~]$ conda --version
conda 4.10.3

  • conda install / conda remove
  • conda list

Tip

  • Keep your base env clean! (only the package manager + its deps)
  • Generously create/remove environments for different tools/workflows!

reference :
[1] GCB 2020 Tutorial. site

[2] Conda, bioconda, anaconda, are they different? site

[3] Conda site

[4] Conda channels.site

[5] The Definitive Guide to Conda Environments.site

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值