美文网首页
Anaconda的安装和使用

Anaconda的安装和使用

作者: 笛猪 | 来源:发表于2019-07-24 15:35 被阅读0次

    原文地址:我的博客

    安装

    官方下载地址

    清华源下载地址

    windows下:和其他安装包一样,下载安装就可以

    Linux下:

    • 下载.sh文件(可以用 wget 下载)

    • 有pip的话直接用 pip install Anaconda3-2019.03-Linux-x86_64.sh 安装,没有的话使用 sh Anaconda3-2019.03-Linux-x86_64.sh安装

    • 一路回车(默认),安装过程中会自动添加环境变量。如果环境变量没有添加成功,即输入conda显示没有该命令,则需手动添加。

      vi /etc/profile     # 进入profile文件
      # 在文件末尾添加:
      export PATH=/root/anaconda3/bin:$PATH   #按自己的情况更改路径
      # 保存退出后执行:
      source /etc/profile     # 使配置生效
      

    更换下载源

    清华源 官方教程
    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 --set show_channel_urls yes
    
    中科大
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
    conda config --add channels 
    https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
    conda config --set show_channel_urls yes
    
    恢复默认源
    conda config --remove-key channels
    

    使用

    • 检查Anaconda版本

      conda --version
      
    • 升级当前版本的Anaconda

      conda update conda
      
    • 创建并激活环境

      conda create --name test (python==3.6)   #创建名为test的环境,括号里内容可选,指定python版本或者其他安装包
      conda create -n test     #和上面的命令作用一样
      
    • 列出所有的环境

      conda info -e
      
    • 激活环境

      Linux, OS:

      source activate test
      

      Windows:

      activate test
      
    • 查看当前环境已安装包

      conda list
      
    • 在当前环境中安装包

      conda install numpy       #不该默认源的话下载会慢一些
      pip install numpy         #pip命令安装也是同样支持的
      
    • 退出当前环境

      source deactivate
      
    • 克隆环境

      conda create -n test2 --clone test     #克隆test环境来创建test2环境
      
    • 删除环境

      conda remove -n test    #通常都不成功,反正我是没成功删除过,都是直接去envs目录下将该环境的文件夹删除,作用是一样的
      

    相关文章

      网友评论

          本文标题:Anaconda的安装和使用

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