[Linux] Miniconda安装及其使用
集群环境下安装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='source /path/to/software/conda/conda3/bin/activate'
alias deactative='source /path/to/software/conda/conda3/bin/deactivate'
实际上,我在安装的过程时碰到了问题,不选择加入环境变量,第一次虽然可以成功激活环境,但退出终端后再次进入环境时,怎么也激活不了。这意味着我必要将conda加入环境变量,而且是在安装的时候就加入,否则无法激活环境,就很尴尬了,我不知道别人是否也是如此。
cd miniconda/envs #进入特定环境目录下激活该环境
source ../bin/activate test #no repsonse
验证下是否成功:
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
#指定环境路径
conda create --prefix=/path/to/py36 python=3.6 #注-p/--prefix和-n/--name参数不能同时用
#如果不指定python,安装会默认为conda自带的python版本,即如果安装的是conda2,就是python2,如果是conda3,就是python3.
#最好是每个环境指定python,尤其是和自己使用的保持一致
- 启动或关闭环境
#激活环境
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
软件安装
- 查看要安装的软件是否存在
anaconda avaliable packages
或使用以下命令
conda search bwa
#一般要安装特定版本时才搜索
- 安装相关命令
#安装指定版本
conda install bwa=0.7.17(其他版本将会覆盖)
#指定环境安装
conda install bwa -n test #加-c还可指定频道
#指定软件安装位置
conda install bwa --prefix=/path/to/env/name #安装后可添加环境变量中或使用全路径
#查看安装位置
which bwa #一般而言,软件会安装到环境中的bin下;而包或库会安装在conda/lib/pythonx.x/site-packages
#已安装软件
conda list
#更新软件
conda update bwa
#卸载
conda remove bwa
主要命令回顾
source activate
source deactivate
conda env list
conda create python=2 -n
conda -h
conda --version
conda list # 查看已经安装的包
conda update conda # 升级conda自身
conda update python #更新到最新版本的python
conda search # 查询包
conda install # 安装包
conda install -n test # 将包安装到指定环境
conda env remove -n #删除环境
conda update --all # 更新所有包
conda update # 升级包
conda remove # 移除包
conda remove -n test # 从指定环境中移除包
温馨提示
对于miniconda
的使用,我的建议是如果你是全新的系统,本来就没配置什么东西,那么它或许是个可供选择的好工具。但如果已经配置了一系列软件和环境,而你又必须在miniconda
加入环境变量的前提下才能激活虚拟环境来使用,那么不用也罢,因为我们无法预知它带来什么样的灾难。
补充:
后来我安装了Anaconda3
,并安装的过程选择了初始化(加入环境变量?),需要全路径调用conda
命令,能成功激活虚拟环境,不知道选择不初始化能否成功激活,反正我的环境又发生了变化,鬼知道我经历了什么。Anaconda
的命令和Miniconda
有些不同,看来简化版还是有其缺陷的。
Ref: https://www.jianshu.com/p/edaa744ea47d
https://www.jianshu.com/p/e1d6276ac0c3
https://www.jianshu.com/p/17288627b994
https://vip.biotrainee.com/d/494-conda
[Linux] Miniconda安装及其使用的更多相关文章
- Linux下安装 Posgresql 并设置基本参数
在Linux下安装Postgresql有二进制格式安装和源码安装两种安装方式,这里用的是二进制格式安装.各个版本的Linux都内置了Postgresql,所以可直接通过命令行安装便可.本文用的是Cen ...
- Linux下安装Tomcat服务器和部署Web应用
一.上传Tomcat服务器
- Linux下安装使用Solr
Linux下安装使用Solr 1.首先下载Solr.mmseg4j分词包.tomcat并解压,这用google.百度都可以搜索得到下载地址. 2.因为要使用到中文分词,所以要设置编码,进入tomcat ...
- Linux下安装tar.gz类型的jdk,并配置环境变量
近期因要学习一门技术,必须在Linux下运行,故开始学习如何使用Linux. 在安装jdk时出现了困难,环境变量配置不成功,花了一天时间才搞定,特分享出来,供大家参考. Linux下安装jdk,步骤如 ...
- Linux下安装和配置JDK与Tomcat(升级版)
在这个版本 Linux下安装和配置JDK与Tomcat(入门版) 的基础上优化升级 1.下载相关软件 apache-tomcat-6.0.37.tar.gz jdk-6u25-linux-i586-r ...
- Linux下安装cmake
cmake是一个跨平台的编译工具,特点是语句简单,编译高效,相对于原有的automake更为高效,接下来说明在Linux下安装cmake工具的过程 首先去cmake官网下载cmake安装包,下载界面网 ...
- 阿里云服务器Linux CentOS安装配置(零)目录
阿里云服务器Linux CentOS安装配置(零)目录 阿里云服务器Linux CentOS安装配置(一)购买阿里云服务器 阿里云服务器Linux CentOS安装配置(二)yum安装svn 阿里云服 ...
- 阿里云服务器Linux CentOS安装配置(九)shell编译、打包、部署
阿里云服务器Linux CentOS安装配置(九)shell编译.打包.部署 1.查询当前目录以及子目录下所有的java文件,并显示查询结果 find . -name *.java -type f - ...
- 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定
阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...
随机推荐
- find&正则表达式
标准的正则表示式格式 常用元字符 代码 说明 . 匹配除换行符以外的任意字符 \w 匹配字母或数字或下划线 \s 匹配任意的空白符 \d 匹配数字 \b 匹配单词的开始或结束 ^ 匹配字符串的开始 $ ...
- hystrix的配置说明
在我们的日常开发中,有些时候需要和第三方系统进行对接操作,或者调用其他系统的 api 接口,但是我们不能保证这些第三方系统的接口一定是稳定的,当系统中产生大量的流量来访问这些第三方接口,这些第三方系统 ...
- Noip模拟20 2021.7.19
T1 玩具 题目读错意思直接报零... 拼接方式没读懂以为是个数学题,用卡特兰数,可是的确想多了 数据范围表达出你怎么暴力都行,选择$n^3,dp$ 相当于一片森林,每次多加一条边就合并成一棵树 在$ ...
- TVS管相关知识
在设计中,使用到了TVS管,在之前的设计中没有特别关注TVS管.今天查了一些资料,算是简单的有个了解. TVS管是一种保护器件.它的英文全称为 transient voltage suppressor ...
- Python之@property详解及底层实现介绍
转自:https://blog.csdn.net/weixin_42681866/article/details/83376484 前文 Python内置有三大装饰器:@staticmethod(静态 ...
- 21.6.29 test
\(NOI\) 模拟赛 \(T1\) 正解是个题解难以理解的数论,结果是组合数相加.暴力分拿满了,尝试打了 \(20*20\) 的表,最后大概打出了个三角形的表,并且帮我找到了一些性质.\(45\)p ...
- 【做题记录】CF1451E2 Bitwise Queries (Hard Version)
CF1451E2 Bitwise Queries (Hard Version) 题意: 有 \(n\) 个数( \(n\le 2^{16}\) ,且为 \(2\) 的整数次幂,且每一个数都属于区间 \ ...
- JavaScript复习 1
概括及使用方法: JavaScript编写规范 一般放在<head>-</head>中间 逐行被执行,越短越好 大小写敏感 语句是基本单位 通常以分号表示语句结束 多行语句可以 ...
- TCP粘"包"问题浅析及解决方案Golang代码实现
一.粘"包"问题简介 在socket网络编程中,都是端到端通信,客户端端口+客户端IP+服务端端口+服务端IP+传输协议就组成一个可以唯一可以明确的标识一条连接.在TCP的sock ...
- 攻防世界 WEB 高手进阶区 PHP2 Writeup
攻防世界 WEB 高手进阶区 PHP2 Writeup 题目介绍 题目考点 url 二次解码 index.phps 文件(第一次使用dirsearch可能扫不到,需要加到工具字典里) php 简单语法 ...