安装软件、conda的重新安装及其使用

一、软件安装

软件安装可以参考Jimmy写的软件的安装代码:
生物信息学常见1000个软件的安装代码!
http://www.biotrainee.com/thread-856-1-1.html

安装软件时候

  1. 优先安装能解压直接用的那种,比如:wget命令;(二进制文件的安装,下载,解压,将其放进环境变量即可source一下)
  2. 其次考虑安装到conda环境中,再次考虑直接conda install XX,把它装到miniconda3/bin里;
  3. 最后可以考虑使用 configure make 这种安装方式。
  4. 另外还有脚本的安装命令,例如perl、python等。
  5. 还有系统版本自带的一些安装软件,例如yum,apt-get,cpan,cran,pip,binconda .....

对于每次安装都出现错误,牵扯到usr/local的结构时,或是某些安装路径的问题,尝试一下软件的绝对路径。

二、重新安装conda

不小心将conda删除,想重新安装。

1.彻底删除conda相关

进入.bashrc查看conda的原来的环境变量,找到conda的位置:/xx/xx/xx/xxxxxx,查看是否删除干净;然后重新进入.bashrc中,删除conda原来的环境变量,

vim ~/.bashrc
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/xx/xx/xx/xxxxxxx' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/xx/xx/xx/xxxxxxx/etc/profile.d/conda.sh" ]; then
        . "/xx/xx/xx/xxxxxxxetc/profile.d/conda.sh"
    else
        export PATH="/xx/xx/xx/xxxxxxx/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

2.重新安装

conda对应着Python的版本 ,查看自己所在的系统的python的版本,在官网上找到合适的conda的版本,通常情况下,下载miniconda(anaconda是包含一些常用包的版本,miniconda则是精简版,需要啥装啥,此处安装的是miconda)

wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh

(可以给其添加执行权限:chmod 777 Miniconda3-py39_4.9.2-Linux-x86_64.sh
安装

bash Miniconda3-py39_4.9.2-Linux-x86_64.sh

按照提示按回车键ENTER或者是yes;
在选择安装到的目录时,可以指定你想要安装的目录(/xx/xx/xx/xxxxxxx/);设定的安装目录要和后边设置的环境变量保持一致;
在询问是否将miniconda添加到环境变量时,输入yes将自动添加到环境变量中,若是按回车键ENTER,则不会自动添加到环境变量中,后面需要自己手动添加;
不管是自动添加的环境变量还是手动添加的环境变量,都需要source ~/.bashrc
这样的话,才能用conda代替/xx/xx/xx/xxxxxxx/conda

可以用其进行测试。

conda -V

三、conda3设置python2的环境

1.安装conda的虚拟环境——python2(你创建的虚拟环境的名字)

conda create -n python2 python=2.7

2.转换到Python2的环境

conda activate python2
conda deactivate##退出当前环境

四、conda的基本命令

参考https://docs.conda.io/projects/conda/en/4.6.0/commands/clean.html

conda install XXXX ##安装软件
conda install -c bioconda XXXX ##安装生物类软件
# 建议直接去Anaconda网站(https://anaconda.org/) 搜索,使用提供的参考命令进行下载

conda uninstall XXXX  ## 卸载该环境中的某软件

conda info -e  ## 查看已创建的环境
conda remove -n XXXX --all  ## 移除某环境

conda list  ## 查看conda安装了哪些包
conda env list  ## 和 conda info -e 一样,查看安装的虚拟环境

......

五、报错

Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64/current_repodata.json>
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.
'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64'

解决方案:

1.连接网络的信号不好,重新尝试上述安装命令
2.若是重新尝试仍报错,更换下载源

vim ~/.condarc ##进入conda的配置文件

更换成清华的源,并将- defaults此选项进行移除;再重新尝试安装命令

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true

查看下载源(镜像)

conda config --get channels

conda下载

wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh
(可以给其添加执行权限:chmod 777 Miniconda3-py39_4.9.2-Linux-x86_64.sh)
安装
bash Miniconda3-py39_4.9.2-Linux-x86_64.sh

按照提示按回车键ENTER或者是yes;
在选择安装到的目录时,可以指定你想要安装的目录(/data/mahuizhen/01-biosoft/miniconda3)
在询问是否将miniconda添加到环境变量时,输入yes将自动添加到环境变量中,若是按回车键ENTER,则不会自动添加到环境变量中,后面需要自己手动添加;


# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/data/mahuizhen/01-biosoft/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/data/mahuizhen/01-biosoft/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/data/mahuizhen/01-biosoft/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/data/mahuizhen/01-biosoft/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

不管是自动添加的环境变量还是手动添加的环境变量,都需要source ~/.bashrc
这样的话,才能用conda代替/data/mahuizhen/01-biosoft/miniconda3/bin/conda

conda -V 可以用其进行测试。

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sh Miniconda3-latest-Linux-x86_64.sh

按照提示按回车键ENTER或者是yes;
在选择安装到的目录时,可以指定你想要安装的目录(/data/mahuizhen/01-biosoft/miniconda3)
在询问是否将miniconda添加到环境变量时,输入yes将自动添加到环境变量中,若是按回车键ENTER,则不会自动添加到环境变量中,后面需要自己手动添加;
不管是自动添加的环境变量还是手动添加的环境变量,都需要source ~/.bashrc

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容