目录
一、软件安装及conda管理
1.conda下载
2.miniconda安装
二、环境配置
1.配置镜像:
2.创建环境、移除环境:
3.查看小环境
4.进入、退出小环境
5.查找并安装软件
三、一步到位
其他:
参考资料:
conda可以来管理大量的生物信息学软件,或者想要复现一些文章中的实验结果需要不同环境的切换。
(1)anaconda
anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirrorhttps://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
(2)miniconda:
Index of /anaconda/miniconda/ | 清华大学开源软件镜像站 | Tsinghua Open Source MirrorIndex of /anaconda/miniconda/ | 清华大学开源软件镜像站,致力于为国内和校内用户提供高质量的开源软件镜像、Linux 镜像源服务,帮助用户更方便地获取开源软件。本镜像站由清华大学 TUNA 协会负责运行维护。https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/选择其中一个下载,不需要同时安装两个)
wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda2-latest-Linux-x86_64.sh
#miniconda下载 #wget c- 加上相应的软件版本即可下载
linux下的.condarc目录如下:- Linux:${HOME}/.condarc 注意:若管理者安装该软件,此步骤可忽略。
安装最新版本的linux版示例:
bash Miniconda2-latest-Linux-x86_64.sh #安装,后续可能会出现如下提示
Please, press ENTER to continue
>>>
# 遇上yes输入yes,其他点击enter
===================================
Miniconda End User License Agreement
===================================
.......
# 点击好几次空格键,直到出现
Do you accept the license terms? [yes|no]
[no] >>>
# 如果输入错误,按enter,重新输入yes
[/home/you/miniconda2] >>>
#绝对安装路径
installation finished.
Do you wish the installer to initialize Miniconda2
in your /home/you/.bashrc ? [yes|no]
[no] >>>
# 输入yes:~/.bashrc这里文件里结尾添加了conda的配置信息
# less ~/.bashrc,多出来的配置信息第一行如下:
# added by Miniconda2 4.5.12 installer
.......
Thank you for installing Miniconda2!
conda --help
# 检验安装是否成功,标志:出现conda的帮助文档信息
#不管安装什么软件,都要记得检测是否安装成功
# 如下所示
usage: conda [-h] [-V] command ...
conda is a tool for managing and deploying applications, environments and packages.
Options:
......
# 继续调取conda子命令的帮助文档,了解相关信息,如
conda create --help
conda install --help
如果失败:
删除安装目录,如果安装到了/home/you/miniconda2里,执行rm -r /home/you/miniconda2
删掉~/.bashrc最后几行conda写入的信息(# added by Miniconda2 4.5.12 installer下面几行一般都是)
如果没有# added by Miniconda2 4.5.12 installer的话,即表明conda配置的信息没写入成功
重新安装
复制一句运行一句,没有提示证明安装成功,配置信息保存在 ~/.condarc 里。
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free conda
config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda
config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda conda
config --set show_channel_urls yes
可能会运行的错误:
报错:
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.
实际上已经设置好镜像,那么指定channel 可以解决bug
conda install -y -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda homer
conda: command not found
# 表明环境变量里找不到conda这个软件
# 出错原因:.bashrc里没有配置conda的PATH或者配置过但是没有source ~/.bashrc
# 检验方法:运行echo $PATH,查看是否含有conda安装路径
Warning: 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge' already in 'channels' list, moving to the top
# 之前已经运行过这句代码
# 复制镜像配置语句时复制错误,需要重新配置时,需要删除镜像配置文件
rm ~/.condarc
安装软件前,先设置一个小环境,环境坏了,可以直接删除,重新设置。
conda create -n rna## 创建一个小环境名为rna
conda create -n rna python=2# 创建一个小环境名为rna,并在此环境下安装python 3
conda env remove --name bio-env#删除小环境及里面的内容
conda info -e
conda info --envs
conda env list
# 都是来查看已经存在小环境
# 运行后如下:rna即为刚刚建立成功的小环境名
$ conda info -e
# conda environments:
#
base * /home/you/miniconda2
rna /home/you/miniconda2/envs/rna
source activate rna#进入小环境
conda deactivate#linux下conda退出小环境命令
conda search PACKAGENAME#运行命令查找是否存在
或者:http://bioconda.github.io/conda-recipe_index.html
conda install 软件名 #安装软件,调取帮助文档,确定是否安装成功
conda install numpy=1.11 #安装能模糊匹配到numpy版本为1.11
conda install numpy==1.11 #精确安装numpy为1.11的版本
conda update conda#更新conda,conda update+软件名称
conda list#在当前小环境下,查看所有安装软件
source activate rna
conda list#列举rna小环境内安装的所有软件
wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda2-latest-Linux-x86_64.sh
# miniconda2软件下载成功
bash Miniconda2-latest-Linux-x86_64.sh
# 遇到yes/no输入yes,其他enter
source ~/.bashrc
conda --help
# miniconda2安装成功,并成功配置好环境变量
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
conda config --set show_channel_urls yes
# 配置镜像
conda create -n rna python=2
# 创建小环境成功,并成功安装python2版本
# 每建立一个小环境,都要装一个python=2的软件作为依赖
source activate rna
# 成功激活进入小环境,可安装软件
conda install -y fastqc
# 出现三个done,即表示安装成功,否则重新提交命令
fastqc --help
# 成功出现帮助文档,fastqc软件安装成功
conda install -y sra-tools
# 出现三个done,即表示安装成功,否则重新提交命令
prefetch --help
# 出现帮助文档,sra-tools软件安装成功
# 安装什么软件--help
source deactivate
# 成功退出rna小环境
# 或直接退出当前账户
pip安装
1.先安装python,才能使用pip安装python的软件,如pip install multiqc
2.软件冲突,同一个流程的两个python软件基于不同版本的python包,只能把冲突的工具安装到不同的子环境。
Tips:网络时代,大家要多多利用网络解决自己遇到的问题呀!
anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
conda管理生信软件一文就够
3个学生的linux视频学习笔记