1. 寻找软件所在的镜像
用conda安装软件的标准语法格式为:
$ conda install -c <channel> <software>
其中-c
这个参数很重要,通过它来指定软件下载的镜像位置
对于我们这些生物信息学的从业人员来说,最常用的channel(这里可以理解成镜像)就是bioconda了,如果想要安装生物信息学,一般都会先到 bioconda官网 上找一找自己想要的软件在不在bioconda的官方镜像的列表中
这里以搜索BWA为例如果软件正好在bioconda官方镜像里,万事大吉,直接用下面的命令安装就可以了
$ conda install -c bioconda bwa
如果你已经将bioconda这个channel加到自己的默认channel列表中,则不指定-c
参数也可以
但是如果你要的软件不在bioconda中怎么办?
这时你可以通过执行 anaconda search -t <software>
来列出保存目标软件的所有官方镜像
比如,如果你要安装CNVnator(这是一个安装过程神级坑的软件),它就不在bioconda中,执行
$ anaconda search -t cnvnator
得到的检索结果如下:
Using binstar api site https://api.anaconda.org
Run 'anaconda show <USER/PACKAGE>' to get more details:
Packages:
Name | Version | Package Types | Platforms
------------------------- | ------ | --------------- | ---------------
pwwang/cnvnator | 0.3.3 | conda | linux-64
: a tool for CNV discovery and genotyping from depth-of-coverage by mapped reads
Found 1 packages
通过上面的检索结果我们就知道目前只有唯一一个保存CNVnator的conda镜像,为pwwang,这是就可以通过指定刚才找到的镜像完成软件的安装了:
$ conda install -c pwwang cnvnator
2. conda中的Python与系统自带的Python打架
在你安装完conda(不论是Anaconda还是Miniconda),它会自带安装对应的Python版本,而你的系统原先也安装了Python,这时两个来源两个版本的Python会发生冲突,使得你新安装的conda运行报错,比如简单地运行 conda list
,会出现以下一长串的报错信息:
Error processing line 1 of /usr/local/lib/python2.7/site-packages/matplotlib-2.1.2-py2.7-nspkg.pth:
Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
File "/disk2/yut/SOFTWARE/miniconda3/lib/python3.7/site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/disk2/yut/SOFTWARE/miniconda3/lib/python3.7/importlib/util.py", line 14, in <module>
from contextlib import contextmanager
File "/disk2/yut/SOFTWARE/miniconda3/lib/python3.7/contextlib.py", line 5, in <module>
from collections import deque
File "/disk2/yut/SOFTWARE/miniconda3/lib/python3.7/collections/__init__.py", line 27, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/usr/local/lib/python2.7/site-packages/reprlib/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/site.py", line 73, in <module>
__boot()
File "/usr/local/lib/python2.7/site-packages/site.py", line 47, in __boot
addsitedir(item)
File "/disk2/yut/SOFTWARE/miniconda3/lib/python3.7/site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "/disk2/yut/SOFTWARE/miniconda3/lib/python3.7/site.py", line 178, in addpackage
import traceback
File "/disk2/yut/SOFTWARE/miniconda3/lib/python3.7/traceback.py", line 3, in <module>
import collections
File "/disk2/yut/SOFTWARE/miniconda3/lib/python3.7/collections/__init__.py", line 27, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/usr/local/lib/python2.7/site-packages/reprlib/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
仔细阅读上面的报错信息,你会发现这就是系统的Python和conda里的Python冲突了(我喜欢称这种现象为掐架、打架),这也是conda这个软件安装神器在给你带来方便的同时带来的副产品:它会污染你的环境变量!
遇到两个Python环境冲突的情况,我一般的解决情况就是,关闭系统的Python,即将系统的Python路径从我的环境变量中删除
$ export PYTHONPATH=''
再执行conda list
就不会再报错了
3. 软件太大老是下载中断
在用conda安装软件的过程中还会经常遇到的一个问题,就是:
我要下载一个软件,conda会告诉我这个软件底层依赖好几个其他的软件,需要将它们一起下载安装,这个时候这一大堆软件中可能有几个体量很大,上百MB,很容易下着下着网络连接就中断了,而conda有没有断点下载功能,一旦下载中断,conda就会终止安装进程退出运行
这个时候你可以尝试通过 wget
把那几个很大的软件的安装包下到本地,然后把它们移到conda的默认安装包下载路径下,这样再执行conda install
时,就会跳过这几个软件的下载过程
conda的默认安装包下载保存路径为:miniconda3/pkgs
网友评论