Ubuntu16.04下Anaconda的安裝和解除安裝
阿新 • • 發佈:2018-12-13
一、去官網下載Anaconda,我下載的是Anaconda3
二、安裝Anaconda3
1、下載完成後命令列進入 Anaconda3-5.3.1-Linux-x86_64.sh 所在的路徑:
[email protected]:~/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是否安裝成功
重新開啟一個終端,輸入pyhton
[email protected]:~$ 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進行託管
四、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.