前言
有時候我們使用 linux 介面的時候,不見得都有 GUI 能夠使用,
這邊記錄一下純用指令安裝 anaconda 的過程。
安裝 anaconda
這是我需要的,所以留在這邊
方法一:透過 wget 取得安裝腳本
bash Anaconda-latest-Linux-x86_64.sh
wget -P /tmp https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
sha256sum /tmp/Anaconda3-2021.05-Linux-x86_64.sh
bash /tmp/Anaconda3-2021.05-Linux-x86_64.sh
方法二:透過 curl 取得安裝腳本
# 安裝 anaconda
cd /tmp
sudo apt install curl -y
curl -O https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
sha256sum Anaconda3-2021.05-Linux-x86_64.sh
bash Anaconda3-2021.05-Linux-x86_64.sh
安裝 anaconda 過程中的注意事項 (注意 conda init !!!!!)
記得以上兩種安裝方式中,有個 conda init 的選項,
如果想要 terminal 預設啟動就是 conda 環境,強烈建議要選 yes !!!
(他預設給 no,但我覺得大家的習慣來說應該更希望 yes)
啊如果不小心就一直按 Enter,應該也會不小心把 conda init 的選項按成 no,
沒關係我們就自己去改,去修改 vim ~/.bashrc (或看你的 shell 也許是 ~/.zshrc)
找個地方補一下以下這段:
(記得使用者要改啊! 如果你使用者名稱不是 ubuntu,記得改成你的名稱)
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/ubuntu/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/ubuntu/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/ubuntu/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/ubuntu/anaconda3/bin:$PATH"
# export PATH="/home/ubuntu/anaconda3/envs/mlenv/bin:$PATH"
# set python3 as default
# export PATH="/home/ubuntu/anaconda/envs/python3/bin:$PATH"
fi
fi
unset __conda_setup
# conda config --set auto_activate_base false
# conda activate myenv
# <<< conda initialize <<<
(optional) 隨便建立一個測試的環境
只是測試用,可不做。
(記得要重新啟動 terminal 修改才會生效)
conda list
conda create --name myenv python=3
conda activate myenv
Reference
- 要確認最新版本 Anaconda 請至此:https://repo.anaconda.com/archive/