Conda的安装

作者: 泥人吴 | 来源:发表于2018-11-26 00:02 被阅读0次

    下载+安装Conda

    • 清华镜像下载
    #首先创建一个文件夹src(源代码的意思),将下载的软件保存到其中
    #下载Miniconda3.4
     wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh
    
    #下载完成后,安装:
    vip39@VM-0-15-ubuntu:~/src$ bash Miniconda3-4.5.11-Linux-x86_64.sh 
    
    # 一直默认,直到...
    installation finished.
    Do you wish the installer to prepend the Miniconda3 install location
    to PATH in your /home/vip39/.bashrc ? [yes|no]
    [no] >>> 
    # 选择no:推荐是这样,防止后期变量冲突
    
    # 启动:
    vip39@VM-0-15-ubuntu:~/src$ source ~/miniconda3/bin/activate
    (base) vip39@VM-0-15-ubuntu:~/src$ 
    # 会发现前面多了个(base),表示目前处于conda环境
    #
    

    查找bwa:

    (base) vip39@VM-0-15-ubuntu:~/src$ conda search bwa
    Loading channels: done
    
    PackagesNotFoundError: The following packages are not available from current channels:
    
      - bwa
    
    Current channels:
    
      - https://repo.anaconda.com/pkgs/main/linux-64
      - https://repo.anaconda.com/pkgs/main/noarch
      - https://repo.anaconda.com/pkgs/free/linux-64
      - https://repo.anaconda.com/pkgs/free/noarch
      - https://repo.anaconda.com/pkgs/r/linux-64
      - https://repo.anaconda.com/pkgs/r/noarch
      - https://repo.anaconda.com/pkgs/pro/linux-64
      - https://repo.anaconda.com/pkgs/pro/noarch
    
    To search for alternate channels that may provide the conda package you're
    looking for, navigate to
    
        https://anaconda.org
    
    and use the search bar at the top of the page
    

    下载anaconda

    • 到清华镜像下载:
    1. Anaconda的仓库镜象
    2. Conda的三方源:Conda Forage ;bioconda
    #查看环境变量:
    (base) vip39@VM-0-15-ubuntu:~/src$ vim ~/.condarc
    # 目前有的channels:
    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/
      - defaults
    show_channel_urls: true
    # bioconda需要放在第一位,优先搜索软件;forge第二位
    

    学习conda的基本操作:

    # 搜索bwa软件
    (base) vip39@VM-0-15-ubuntu:~/src$ conda search bwa
    # 上面这个步骤将耗费时间:
    
    # 下载bwa:-y表示其余默认
    (base) vip39@VM-0-15-ubuntu:~/src$ conda install bwa -y
    Solving environment:... #帮我们解决环境变量的问题
    
    • 下载samtools:
    (base) vip39@VM-0-15-ubuntu:~/src$ conda install samtools=1.8 -y
    # 1.8 表示samtools的版本号
    
    #运行samtools,可以直接输入samtools,因为:
    (base) vip39@VM-0-15-ubuntu:~/src$ source ~/miniconda3/bin/activate 
    # 这一步实现了如下:
    (base) vip39@VM-0-15-ubuntu:~/src$ echo $PATH
    /home/vip39/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
    # minconda3存在于我们的环境变量中了
    

    创建软链接:

    # 退出目前环境:
    (base) vip39@VM-0-15-ubuntu:~/src$ source deactivate
    vip39@VM-0-15-ubuntu:~/src$ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
    # 这个时候直接的samtools是不能安装的(其实我是可以的),那么可以:
    # 通过软件实际路径进行:
    vip39@VM-0-15-ubuntu:~/src$ ~/miniconda3/bin/samtools
    
    # 或者可以创建软链接:
    # samtools问题待解决
    

    conda 的环境变量

    (base) vip39@VM-0-15-ubuntu:~$ conda info --envs
    # conda environments:
    #
    base                  *  /home/vip39/miniconda3
    
    # 目前为miniconda3,支持的是python2;
    # 想要安装macs2(python2环境下进行的);需要建立一个python2的环境
    # 不要直接安装,否则会把python3变成python2,导致后期的报错。
    # 建立python2的环境:
    (base) vip39@VM-0-15-ubuntu:~$ conda create -n python2 python=2
    ...
    #
    # To activate this environment, use
    #
    #     $ conda activate python2 #表示启动python2的环境
    #
    # To deactivate an active environment, use
    #
    #     $ conda deactivate
    
    (base) vip39@VM-0-15-ubuntu:~$ conda activate python2
    (python2) vip39@VM-0-15-ubuntu:~$
    
    # 目前python2的环境下安装macs2:
    (python2) vip39@VM-0-15-ubuntu:~$ conda install macs2
    # 查看一下macs2的环境变量:
    (python2) vip39@VM-0-15-ubuntu:~$ which macs2
    /home/vip39/miniconda3/envs/python2/bin/macs2
    
    # 启动macs2的方法:
    (python2) vip39@VM-0-15-ubuntu:~$ source deactivate
    (base) vip39@VM-0-15-ubuntu:~$ masc2
    No command 'masc2' found, did you mean:
     Command 'macs2' from package 'macs' (universe)
    masc2: command not found
    (base) vip39@VM-0-15-ubuntu:~$ ~/miniconda3/envs/python2/bin/macs2 
    usage: macs2 [-h] [--version]
                 {callpeak,bdgpeakcall,bdgbroadcall,bdgcmp,bdgopt,cmbreps,bdgdiff,filterdup,predictd,pileup,randsample,refinepeak}
                 ...
    macs2: error: too few arguments
    (base) vip39@VM-0-15-ubuntu:~$ ln -s ~/miniconda3/envs/python2/bin/macs2 ~/.local/bin/
    (base) vip39@VM-0-15-ubuntu:~$ macs2
    The program 'macs2' is currently not installed. To run 'macs2' please ask your administrator to install the package 'macs'
    

    相关文章

      网友评论

        本文标题:Conda的安装

        本文链接:https://www.haomeiwen.com/subject/oowmqqtx.html