天天看點

男神鵬:linux伺服器下非root權限安裝anaconda 以及 linux下使用anaconda建立python虛拟環境(以Anaconda3-5.0.1-Linux-x86_64.sh為例)

 一:安裝anaconda

1.找到自己需要的anaconda版本并下載下傳下來(可以用迅雷下載下傳~速度還快點~),上傳到伺服器自己目錄下;

下載下傳位址:https://repo.anaconda.com/archive/

或者清華鏡像:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

2.cd到anaconda安裝包目錄下,安裝anaconda:

# bash Anaconda3-5.0.1-Linux-x86_64.sh

3.按enter浏覽完協定以後,輸入yes同意協定(注意再選擇安裝路徑的時候,按enter即可安裝在預設目錄下,不要再輸入yes~,否則就安裝在yes目錄下了~ T_T)

4.運作conda指令,此時可能提示找不到conda指令,使用指令(xxx為自己的使用者名):

# echo 'export PATH="/home/xxx/anaconda3/bin:$PATH"'>>~/.bashrc

# source ~/.bashrc

男神鵬:linux伺服器下非root權限安裝anaconda 以及 linux下使用anaconda建立python虛拟環境(以Anaconda3-5.0.1-Linux-x86_64.sh為例)

即可使用conda指令。

二:建立虛拟環境并使用

一般情況下我們每一個python項目都盡可能的使用一個獨立的python環境,這樣便于進行包的管理,下面整理一下如何利用anaconda來建立一個幹淨的python虛拟環境,

1、首先系統中需要安裝的有anaconda,然後才可以使用conda指令:輸入conda,進入conda環境

男神鵬:linux伺服器下非root權限安裝anaconda 以及 linux下使用anaconda建立python虛拟環境(以Anaconda3-5.0.1-Linux-x86_64.sh為例)

 2、conda create --name 環境名稱 pytohn==3.6     此處輸入你要建立的環境名稱,和你需要的python版本

男神鵬:linux伺服器下非root權限安裝anaconda 以及 linux下使用anaconda建立python虛拟環境(以Anaconda3-5.0.1-Linux-x86_64.sh為例)

3、提示框中輸入y

4、到此環境就建立成功了:輸入source activate  huahua(環境名) 進入我們建立的環境

男神鵬:linux伺服器下非root權限安裝anaconda 以及 linux下使用anaconda建立python虛拟環境(以Anaconda3-5.0.1-Linux-x86_64.sh為例)

conda的指令:

男神鵬:linux伺服器下非root權限安裝anaconda 以及 linux下使用anaconda建立python虛拟環境(以Anaconda3-5.0.1-Linux-x86_64.sh為例)