Ubuntu16.04下Anaconda的安装和卸载

【详细】Ubuntu 下安装 Anaconda_ubuntu安装anaconda-CSDN博客

一、去官网下载Anaconda,我下载的是Anaconda3

二、安装Anaconda3

1、下载完成后命令行进入 Anaconda3-5.3.1-Linux-x86_64.sh 所在的路径:

vision@vision-PC:~/Downloads$ bash Anaconda3-5.3.1-Linux-x86_64.sh 
Welcome to Anaconda3 5.3.1
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>> 

然后根据提示,按回车确认。
它会提示你是否接受协议,这里直接输入yes,再按回车即可(不要直接按回车,这样默认是no)

Do you accept the license terms? [yes|no]
[no] >>> yes

接下来会提示你指定安装路径,这里可以使用默认的,也可以自己指定,最好自己指定安装路径,方便以后维护

Anaconda3 will now be installed into this location:
/home/vision/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/vision/anaconda3] >>> /home/vision/Softwares/Anaconda3  #自己定义的安装路径

然后就是等待安装进程完成,完成后会提示你是否要将Anaconda的安装路径添加到PATH环境变量中必须输入yes(不要直接按回车,这样默认是no),否则需要自己设置环境变量。

installation finished.
Do you wish the installer to prepend the Anaconda3 install location
to PATH in your /home/hj/.bashrc ? [yes|no]
[no] >>> yes

配置后的环境遍历如下:

# added by Anaconda3 5.3.1 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/home/vision/Softwares/Anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/home/vision/Softwares/Anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/vision/Softwares/Anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/home/vision/Softwares/Anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

之后就是等待安装完成,Anaconda3 安装完成提示是否安装VSCode,这里选择yes。如下:

For this change to become active, you have to open a new terminal.

Thank you for installing Anaconda3!

===========================================================================

Anaconda is partnered with Microsoft! Microsoft VSCode is a streamlined
code editor with support for development operations like debugging, task
running and version control.

To install Visual Studio Code, you will need:
  - Administrator Privileges
  - Internet connectivity

Visual Studio Code License: https://code.visualstudio.com/license

Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
>>> 


Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
>>> yes
Proceeding with installation of Microsoft VSCode
VSCode is already installed!

三、验证Anaconda3是否安装成功

首先更新一下文件,使配置生效

source ~/.bashrc

重新打开一个终端,输入pyhton

vision@vision-PC:~$ 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.
>>> 

如上图所示, python环境已经自动由Anaconda进行托管

四、Anaconda安装后的配置

1、conda install 加速

更详细的设置参考另一篇文章:pip install 和 conda install 使用国内镜像源,提升下载速度_pip install -c-CSDN博客

基本下面的就可以了

一般默认的conda install 安装相关库时是非常慢的,这就需要更换源(清华的源)

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 --remove-key channels

2、在jupyter notebook下使用anaconda虚拟环境

conda install nb_conda_kernels

再重新开启Jupyter Notebook:(注:我重启后发现依然找不到,后来系统重启后可以找到Anaconda的虚拟环境了,所以如果找不到试试系统重启吧

如下图,新建一个 .ipynb文件时可以选择使用的python环境。其中 Python [default] 是系统自带的python环境。

同时对已有的 .ipynb 文件也可以切换其使用的python环境:如下图

Kernel->Change kernel -> 选择更换的python环境

3、在jupyter notebook下 .ipynb 文件保存为python文件

File -> Download as -> 选择保存文件格式

五、Anaconda3的卸载

1、删除整个anaconda目录: 
由于Anaconda的安装文件都包含在一个目录中,所以直接将该目录删除即可。到包含整个anaconda目录的文件夹下,删除整个Anaconda目录:

rm -rf Anaconda3安装路径

2、清理下.bashrc中的Anaconda路径:

打开终端并输入: 

sudo gedit ~/.bashrc

在.bashrc文件末尾,删除掉Anaconda3写入的东西

# added by Anaconda3 5.3.1 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/home/vision/Softwares/Anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/home/vision/Softwares/Anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/vision/Softwares/Anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/home/vision/Softwares/Anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

保存并关闭文件

3.使其立即生效,在终端执行: 

source ~/.bashrc

4.关闭终端,然后再重启一个新的终端,这一步很重要,不然在原终端上还是绑定有Anaconda3.

  • 2
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值