Published at 2020-05-03 11:37
Author:zhixy
View:1017
Conda 是一个开源的软件包管理系统和环境管理系统,用于安装多个版本的软件包及其依赖关系,并在它们之间轻松切换。 Conda 是为 Python 程序创建的,适用于 Linux,OS X 和Windows,也可以打包和分发其他软件。
Conda分为anaconda和miniconda。anaconda是包含一些常用包的版本(这里的常用不代表你常用 微笑.jpg), miniconda则是精简版,所以推荐使用miniconda。
通过conda search
可查询软件源中是否有需要的相关软件,-c
追加搜索的软件源通道。生物信息学相关软件多数可在bioconda中找到。
(base) [user@server ~]# conda search -c bioconda iqtree
Loading channels: done
# Name Version Build Channel
iqtree 1.5.3 0 bioconda
iqtree 1.5.3 1 bioconda
iqtree 1.5.3 he941832_2 bioconda
iqtree 1.5.5 0 bioconda
iqtree 1.5.5 1 bioconda
iqtree 1.5.5 he941832_2 bioconda
iqtree 1.6.6 he941832_0 bioconda
iqtree 1.6.7 he941832_0 bioconda
iqtree 1.6.7 he941832_1 bioconda
iqtree 1.6.7.1 he941832_0 bioconda
iqtree 1.6.7.2 he941832_0 bioconda
iqtree 1.6.8 he941832_0 bioconda
iqtree 1.6.9 he860b03_1 bioconda
iqtree 1.6.9 he941832_0 bioconda
iqtree 1.6.10 he860b03_0 bioconda
iqtree 1.6.11 he860b03_0 bioconda
iqtree 1.6.11.1 he513fc3_0 bioconda
iqtree 1.6.12 he513fc3_0 bioconda
iqtree 1.6.12 he513fc3_1 bioconda
iqtree 2.0.3 h176a8bc_0 bioconda
将search
改为install
即可安装:
(base) [user@inspur ~]# conda install -c bioconda iqtree
Conda默认的基本环境base,依赖的python版本是3.7(或其他)。有时目标软件依赖的python版本是2.7, Conda通过创建虚拟环境来解决版本依赖问题。首先通过一下命令可查看系统中已存在的虚拟环境:
(base) [user@server ~]# conda env list
# conda environments:
#
base * /opt/miniconda3
iqtree1.6.8 /opt/miniconda3/envs/iqtree1.6.8
metawrap-env /opt/miniconda3/envs/metawrap-env
orthofinder /opt/miniconda3/envs/orthofinder
qiime2 /opt/miniconda3/envs/qiime2
通过conda create
可创建一个环境:
(base) [user@server ~]# conda create -n python2 python=2.7
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/user/.conda/envs/python2
added / updated specs:
- python=2.7
The following packages will be downloaded:
package | build
---------------------------|-----------------
_libgcc_mutex-0.1 | main 3 KB
ca-certificates-2020.1.1 | 0 125 KB
certifi-2019.11.28 | py27_0 153 KB
libffi-3.3 | he6710b0_1 50 KB
ncurses-6.2 | he6710b0_1 817 KB
python-2.7.18 | h15b4118_1 9.9 MB
readline-8.0 | h7b6447c_0 356 KB
setuptools-44.0.0 | py27_0 512 KB
sqlite-3.31.1 | h62c20be_1 2.0 MB
------------------------------------------------------------
Total: 13.8 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main
ca-certificates pkgs/main/linux-64::ca-certificates-2020.1.1-0
certifi pkgs/main/linux-64::certifi-2019.11.28-py27_0
libedit pkgs/main/linux-64::libedit-3.1.20181209-hc058e9b_0
libffi pkgs/main/linux-64::libffi-3.3-he6710b0_1
libgcc-ng pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0
libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
ncurses pkgs/main/linux-64::ncurses-6.2-he6710b0_1
pip pkgs/main/linux-64::pip-19.3.1-py27_0
python pkgs/main/linux-64::python-2.7.18-h15b4118_1
readline pkgs/main/linux-64::readline-8.0-h7b6447c_0
setuptools pkgs/main/linux-64::setuptools-44.0.0-py27_0
sqlite pkgs/main/linux-64::sqlite-3.31.1-h62c20be_1
tk pkgs/main/linux-64::tk-8.6.8-hbc83047_0
wheel pkgs/main/linux-64::wheel-0.33.6-py27_0
zlib pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3
Proceed ([y]/n)?
安装过程中需要确认安装该环境需要的软件包,另外-n
定义了环境的名称。
安装完成后,通过以下命令进入虚拟环境:
(base) [user@server ~]# conda activate python2
(python2) [user@server ~]#
(python2) [user@server ~]# conda deactivate
(base) [user@server ~]# conda remove -n python2 --all