Ubuntu16.04LTS Anaconda安裝與使用tips

Ubuntu16.04LTS  Anaconda安裝與使用tips

Anaconda安裝: 

清華鏡像源download link: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/


如上圖,隨便選個較新的就行linux版本就行,然後我是64位機。

下載.完sh文檔,所在文件夾下打開終端,然後執行必要的話sudo執行:

bash Anaconda3-xxxxxxxxxx.sh


一直回車到安裝結束。好多回車到yes,會提醒是否修改環境保存路徑,我就使用默認的就行了。

然後提醒環境變量自動添加,顯然我們得選擇是。

然後提醒是否要裝VScode,選擇不用,一般用不到。


然後就結束啦,重啓終端,檢查安裝:

conda --version
sudo gedit ~/.bashrc

檢查末尾是否已經添加如下變量,沒有自己添加:

export PATH="/home/用戶名/anaconda3/bin:$PATH"

下載太慢?

爲了能快點下載東西,建議境內的主機將清華鏡像源添加進conda的源:

官方教程:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

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
即可添加 Anaconda Python 免費倉庫。運行 conda install numpy 測試一下吧。


pip 也可以使用清華軟件源:

官方教程: https://mirrors.tuna.tsinghua.edu.cn/help/pypi/

臨時使用:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
設爲默認:

修改 ~/.config/pip/pip.conf (Linux), %APPDATA%\pip\pip.ini (Windows 10) 或 $HOME/Library/Application Support/pip/pip.conf (macOS) (沒有就創建一個), 修改 index-url至tuna,例如

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
pip 和 pip3 並存時,只需修改 ~/.pip/pip.conf。


環境創建,軟件安裝:以tensorflow爲例

conda create -n jz python==3.6

激活環境:

source activate jz

conda安裝:

conda install tensorflow-gpu
conda install tensorflow-gpu==1.5

第一行默認最新的gpu版,第二行則指定版本

pip 安裝:

pip install tensorflow-gpu
pip install tensorflow-gpu==1.5

或者使用清華鏡像源:

一種方法:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu

推薦另一種到鏡像源網站尋找更靠譜:https://mirror.tuna.tsinghua.edu.cn/help/tensorflow/

直接複製裏面的指令

pip install \
  -i https://pypi.tuna.tsinghua.edu.cn/simple/ \
  https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/gpu/tensorflow_gpu-1.5.0-cp36-cp36m-linux_x86_64.whl


環境卸載:

conda remove -n yourname --all

注:由於anaconda在linux下是安裝在一個文件夾裏/root/anaconda ,如果安裝過程中出錯問題,或者想更新另一個版本,刪除anaconda也很方便,執行下面命令

rm -rf ~/anaconda




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章