環境:Centos 7
1.下載Anaconda
直接在官網下載挺慢的,建議使用清華鏡像(可以把pip的源也換成國內的,pip install也會快很多):Tsinghua Open Source Mirro
在最近的日期中,選擇一個對應自己系統版本的Anaconda3安裝包,x86_64表示兼容32位和64位系統,右鍵復制鏈接,在linux中使用wget下載,
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh
如果提示沒有wget,使用yum安裝:
yum -y install wget
2. 安裝Anaconda
在下載目錄中執行該檔案,根據下載的版本不同,名稱會有不同:
bash Anaconda3-2019.03-Linux-x86_64.sh
接下來會出現一堆的License許可宣告,一路回車向下,出現如下文字,輸入yes:
Do you accept the license terms? [yes|no]
[no] >>>
Please answer 'yes' or 'no':
>>> yes
之后要選擇安裝目錄,如果無需更改直接回車Enter,如需更改要輸入絕對路徑:
(可以先查看下硬碟的掛載情況再自行選擇安裝目錄,查看掛載情況的陳述句是df -h)
Anaconda3 will now be installed into this location:
/home/sw/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/sw/anaconda3] >>>
問是否需要進行conda的初始化,建議輸入no,若選擇yes,是在/root/.bashrc目錄中自動添加環境變數,會使得開機自動啟動base環境,(這里應該是新版安裝包的改動之處,老版本的安裝包都是問是否需要添加conda至環境變數,且默認直接回車Enter是不添加,若未添加后續需要手動添加,)
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> no
看到如下提示則安裝成功:
Thank you for installing Anaconda3!
===========================================================================
Anaconda and JetBrains are working together to bring you Anaconda-powered
environments tightly integrated in the PyCharm IDE.
PyCharm for Anaconda is available at:
https://www.anaconda.com/pycharm
如果conda的初始化時選擇了yes,那么已經配置了環境變數,輸入簡單的命令測驗一下:
conda activate # 進入conda環境 出現(base)則說明安裝成功
conda deactivate # 退出conda環境
這里需要注意的是新版廢用了source activate的命令,如使用舊版安裝包則使用如下命令:
source activate # 進入conda環境 出現(base)則說明安裝成功
source deactivate # 退出conda環境
如果conda的初始化時選擇了no,則需要自行配置環境變數,
打開profile檔案:
vi /etc/profile
在檔案最后加入如下陳述句(路徑需要根據自己的安裝位置更改):
PATH=$PATH:/home/sw/anaconda3/bin
export PATH
按住shift鍵+:鍵,輸入wq,保存檔案并退出,最后使用如下命令重繪環境變數即可:
source /etc/profile
echo $PATH
進入、退出環境使用的也是source開頭的命令:
source activate # 進入conda環境 出現(base)則說明安裝成功
source deactivate # 退出conda環境
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/436317.html
標籤:Python
