Linux(Ubuntu 18.04)上安装Anaconda步骤详解

(编辑:jimmy 日期: 2024/12/27 浏览:2)

Anaconda是最受欢迎的python数据科学和机器学习平台,用于大规模数据处理,预测分析和科学计算。Anaconda发行版附带了1,000多个数据包,conda命令行工具和Anaconda Navigator的桌面图形用户界面。

本教程将指导您完成在Ubuntu 18.04上下载和安装Anaconda Python Distribution。

下载Anaconda

在撰写本文时,Anaconda的最新稳定版本是5.3版本。

Linux(Ubuntu 18.04)上安装Anaconda步骤详解

请选择 64-Bit (x86) Installer 进行下载链接: https://pan.baidu.com/s/1rNA9D8gaGHuIE0Ao_l5AQA 提取码: uecd  。尽量不要用python2.7,很多库已经不提供python2.7支持。

点击链接就会进行下载,同时会弹出信息收集框,直接关闭就好。

Linux(Ubuntu 18.04)上安装Anaconda步骤详解

安装Anaconda

$ sudo sh Anaconda3-5.3.0-Linux-x86_64.sh 
[sudo] andrew 的密码: 
Welcome to Anaconda3 5.3.0
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
> # 按下回车
... # 多次按空格读完license。
Do you accept the license terms"$(CONDA_REPORT_ERRORS=false '/usr/local/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $"$__conda_setup"
else
 if [ -f "/usr/local/anaconda3/etc/profile.d/conda.sh" ]; then
 . "/usr/local/anaconda3/etc/profile.d/conda.sh"
 CONDA_CHANGEPS1=false conda activate base
 else
 \export PATH="/usr/local/anaconda3/bin:$PATH"
 fi
fi
unset __conda_setup~/.bashrc
# <<< conda init <<<

验证安装

通过重新登陆或者执行'source ~/.bashrc"加载环境变量。

$ conda info
 active environment : base
 active env location : /usr/local/anaconda3
  shell level : 1
 user config file : /home/andrew/.condarc
 populated config files : 
  conda version : 4.5.11
 conda-build version : 3.15.1
  python version : 3.7.0.final.0
 base environment : /usr/local/anaconda3 (read only)
  channel URLs : 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
  package cache : /usr/local/anaconda3/pkgs
    /home/andrew/.conda/pkgs
 envs directories : /home/andrew/.conda/envs
    /usr/local/anaconda3/envs
  platform : linux-64
  user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Linux/4.15.0-36-generic ubuntu/18.04 glibc/2.27
  UID:GID : 1000:1000
  netrc file : None
  offline mode : False
$ python
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>

至此,已经安装完毕。

更新Anaconda

一般是有新版本发布时才需要使用。

$ conda update conda
$ conda update anaconda

删除Anaconda

一般是有新版本发布时才需要使用。

$sudo rm -rf /usr/local/anaconda3
删除上面~/.bashrc和/etc/profile的修改
清空隐藏文件: rm -rf ~/.condarc ~/.conda ~/.continuum

总结