集群环境下安装conda
进行软件管理。Miniconda
是Anaconda
的简化版,对于一般需求而言就够用了。因此,我这里安装Minconda3
进行软件安装管理。
Miniconda
下载地址,根据所需选择下载。
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sh Miniconda3-latest-Linux-x86_64.sh
#后续根据提示选择安装路径或添加到环境变量即可
也可手动添加到环境变量:
vi ~/.bashrc
export PATH=/path/to/software/conda/conda3/bin/:$PATH
这里提示一下:有的人说最好不要将conda
加入到环境变量中,因为会污染到非conda
安装的其他软件,造成不可预知的错误Anaconda is a snake. ,这个仁者见仁,智者见智,我还没遇到过。不加入环境变量怎么办?那就只能设置别名来简化输入了。
alias conda='/path/to/software/conda/conda3/bin/conda'
alias actative='. /path/to/software/conda/conda3/bin/activate'
alias deactative='. /path/to/software/conda/conda3/bin/deactivate'
验证下是否成功:
conda -h
报如下错误:
Fatal Python error: Py_Initialize: Unable to get the locale encoding
File "/share/app/python-2.7.10/lib/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError, ^
SyntaxError: invalid syntax
Current thread 0x00007f160e638740 (most recent call first):
说明和系统自带的python2
有冲突,我环境变量中的python
库设置如下:
export PATH=/my/python/software/Python-2.7.15/bin:$PATH
export PYTHONPATH=/my/python/software/Python-2.7.15/lib/python2.7/site-packages:/share/app/python-2.7.10/lib/python2.7/site-packages:/share/app/python-2.7.10/lib/python2.7/:/mygroup/python/software/python/python2.7_lib
可以看到我目前使用的是我自己安装的python2.7.15
,而PYTHONPATH
变量中(可能有些设置为PYTHONHOME
)包括我的python
库,我小组的python
库以及系统自带的python
库。根据报错信息,我将系统自带库去掉,再source
下环境,可以正常显示了,我们可以顺便看下这些参数的用法。
$ conda -h
usage: conda [-h] [-V] command ...
conda is a tool for managing and deploying applications, environments and packages.
Options:
positional arguments:
command
clean Remove unused packages and caches.
config Modify configuration values in .condarc. This is modeled
after the git config command. Writes to the user .condarc
file (/home/pengjianxiang/.condarc) by default.
create Create a new conda environment from a list of specified
packages.
help Displays a list of available conda commands and their help
strings.
info Display information about current conda install.
install Installs a list of packages into a specified conda
environment.
list List linked packages in a conda environment.
package Low-level conda package utility. (EXPERIMENTAL)
remove Remove a list of packages from a specified conda environment.
uninstall Alias for conda remove. See conda remove --help.
search Search for packages and display associated information. The
input is a MatchSpec, a query language for conda packages.
See examples below.
update Updates conda packages to the latest compatible version. This
command accepts a list of package names and updates them to
the latest versions that are compatible with all other
packages in the environment. Conda attempts to install the
newest versions of the requested packages. To accomplish
this, it may update some packages that are already installed,
or install additional packages. To prevent existing packages
from updating, use the --no-update-deps option. This may
force conda to install older versions of the requested
packages, and it does not prevent additional dependency
packages from being installed. If you wish to skip dependency
checking altogether, use the '--force' option. This may
result in an environment with incompatible packages, so this
option must be used with great caution.
upgrade Alias for conda update. See conda update --help.
optional arguments:
-h, --help Show this help message and exit.
-V, --version Show the conda version number and exit.
conda commands available from other packages:
env
解决上述报错的另一个方法就是用unset PYTHONPATH
,即不用环境中python
,然后再使用conda
也是正常的。
需要注意的是,conda
绝大部分命令都是要求在联网的情况下使用的,如果你们单位的集群禁止联网,那这个工具几乎没用。不过一般再严格也会有单独一个节点来联网的,我们下个软件也不会占用太多资源。
官方channel:
conda config --add channels bioconda
conda config --add channels conda-forge
清华镜像:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
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 config --get channels
vim ~/.condarc
# 查看已安装的python环境
conda info -e #conda info --envs
conda env list
#基于python3.6版本创建一个名字为test的python独立环境
conda create --name test python=3.6
#指定python2版本
conda create -n test2 python=2
#激活环境
source activate(后接环境名,不加默认为base)
source activate test
#退出环境
source deactivate test
#PS:若未加入环境变量,需进入conda的bin目录下执行
conda env remove -n test
conda remove -n test --all
即先克隆,再删除
conda create -n python2 --clone py2
conda remove -n py2 --all
conda search bwa
#安装指定版本
conda install bwa=0.7.17(其他版本将会覆盖)
#安装位置
which bwa
#已安装软件
conda list
#更新软件
conda update bwa
#卸载
conda remove bwa
conda --version
conda install matplotlib
conda update conda
conda update python #更新到最新版本的python
Ref: https://www.jianshu.com/p/edaa744ea47d
https://www.jianshu.com/p/e1d6276ac0c3
原文:https://www.cnblogs.com/jessepeng/p/11685170.html