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

简介: conda

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

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

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

目录
相关文章
|
4月前
|
数据库 开发工具 开发者
【Python】已解决:You have 18 unapplied migration(s). Your project may not work properly until you apply t
【Python】已解决:You have 18 unapplied migration(s). Your project may not work properly until you apply t
127 0
|
4月前
|
Python
安装 supervisor报错执行python setup.py install时No local packages or working download links found for meld3
安装 supervisor报错执行python setup.py install时No local packages or working download links found for meld3
31 0
|
6月前
|
缓存 TensorFlow 算法框架/工具
conda 常用命令, Non-zero exit code,You will need to adjust your conda configuration
conda 常用命令, Non-zero exit code,You will need to adjust your conda configuration
182 2
|
6月前
|
资源调度
Yarn install 报错 Resolving packages... [2/4] Fetching packages... info There appears to be trouble wi
Yarn install 报错 Resolving packages... [2/4] Fetching packages... info There appears to be trouble wi
342 0
如何解决 conda install 库时报错:The environment is inconsistent, please check the package plan carefully
如何解决 conda install 库时报错:The environment is inconsistent, please check the package plan carefully
如何解决 conda install 库时报错:The environment is inconsistent, please check the package plan carefully
|
C++ iOS开发
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
链接如下:【金山文档】 1-Microsoft Visual C++ Build Tools。找了好久,才找到正确的解决方案,网上一大堆升级setuptools的方法只对少数人管用。注意,虽然我的这个报错内容有点长,但是我感觉和其它的。如果网页提示登录,可以不用登录,直接下载即可。然后打开镜像ios文件(双击即可)错误是一样的解决方案。文件,打开后安装即可。
2622 1
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
|
Shell Linux C++
报错:CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘. 问题解决
报错:CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘. 问题解决
267 0
|
Ubuntu
问题解决:Ubuntu安装ROS依赖出现ERROR: the following packages/stacks could not have their rosdep keys resolvedt
问题解决:Ubuntu安装ROS依赖出现ERROR: the following packages/stacks could not have their rosdep keys resolvedt
1440 0
ubuntu16.04中ROS-Kinetic报错: not find a package configuration file provided by “gazebo_ros_control“
ubuntu16.04中ROS-Kinetic报错: not find a package configuration file provided by “gazebo_ros_control“
181 0