安裝軟件、conda的重新安裝及其使用

一、軟件安裝

軟件安裝可以參考Jimmy寫的軟件的安裝代碼:
生物信息學(xué)常見(jiàn)1000個(gè)軟件的安裝代碼!
http://www.biotrainee.com/thread-856-1-1.html

安裝軟件時(shí)候

  1. 優(yōu)先安裝能解壓直接用的那種,比如:wget命令;(二進(jìn)制文件的安裝,下載,解壓,將其放進(jìn)環(huán)境變量即可source一下)
  2. 其次考慮安裝到conda環(huán)境中,再次考慮直接conda install XX,把它裝到miniconda3/bin里;
  3. 最后可以考慮使用 configure make 這種安裝方式。
  4. 另外還有腳本的安裝命令,例如perl、python等。
  5. 還有系統(tǒng)版本自帶的一些安裝軟件,例如yum,apt-get,cpan,cran,pip,binconda .....

對(duì)于每次安裝都出現(xiàn)錯(cuò)誤,牽扯到usr/local的結(jié)構(gòu)時(shí),或是某些安裝路徑的問(wèn)題,嘗試一下軟件的絕對(duì)路徑。

二、重新安裝conda

不小心將conda刪除,想重新安裝。

1.徹底刪除conda相關(guān)

進(jìn)入.bashrc查看conda的原來(lái)的環(huán)境變量,找到conda的位置:/xx/xx/xx/xxxxxx,查看是否刪除干凈;然后重新進(jìn)入.bashrc中,刪除conda原來(lái)的環(huán)境變量,

vim ~/.bashrc
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/xx/xx/xx/xxxxxxx' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/xx/xx/xx/xxxxxxx/etc/profile.d/conda.sh" ]; then
        . "/xx/xx/xx/xxxxxxxetc/profile.d/conda.sh"
    else
        export PATH="/xx/xx/xx/xxxxxxx/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

2.重新安裝

conda對(duì)應(yīng)著Python的版本 ,查看自己所在的系統(tǒng)的python的版本,在官網(wǎng)上找到合適的conda的版本,通常情況下,下載miniconda(anaconda是包含一些常用包的版本,miniconda則是精簡(jiǎn)版,需要啥裝啥,此處安裝的是miconda)

wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh

(可以給其添加執(zhí)行權(quán)限:chmod 777 Miniconda3-py39_4.9.2-Linux-x86_64.sh
安裝

bash Miniconda3-py39_4.9.2-Linux-x86_64.sh

按照提示按回車鍵ENTER或者是yes;
在選擇安裝到的目錄時(shí),可以指定你想要安裝的目錄(/xx/xx/xx/xxxxxxx/);設(shè)定的安裝目錄要和后邊設(shè)置的環(huán)境變量保持一致;
在詢問(wèn)是否將miniconda添加到環(huán)境變量時(shí),輸入yes將自動(dòng)添加到環(huán)境變量中,若是按回車鍵ENTER,則不會(huì)自動(dòng)添加到環(huán)境變量中,后面需要自己手動(dòng)添加;
不管是自動(dòng)添加的環(huán)境變量還是手動(dòng)添加的環(huán)境變量,都需要source ~/.bashrc
這樣的話,才能用conda代替/xx/xx/xx/xxxxxxx/conda

可以用其進(jìn)行測(cè)試。

conda -V

三、conda3設(shè)置python2的環(huán)境

1.安裝conda的虛擬環(huán)境——python2(你創(chuàng)建的虛擬環(huán)境的名字)

conda create -n python2 python=2.7

2.轉(zhuǎn)換到Python2的環(huán)境

conda activate python2
conda deactivate##退出當(dāng)前環(huán)境

四、conda的基本命令

參考https://docs.conda.io/projects/conda/en/4.6.0/commands/clean.html

conda install XXXX ##安裝軟件
conda install -c bioconda XXXX ##安裝生物類軟件
# 建議直接去Anaconda網(wǎng)站(https://anaconda.org/) 搜索,使用提供的參考命令進(jìn)行下載

conda uninstall XXXX  ## 卸載該環(huán)境中的某軟件

conda info -e  ## 查看已創(chuàng)建的環(huán)境
conda remove -n XXXX --all  ## 移除某環(huán)境

conda list  ## 查看conda安裝了哪些包
conda env list  ## 和 conda info -e 一樣,查看安裝的虛擬環(huán)境

......

五、報(bào)錯(cuò)

Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64'

解決方案:

1.連接網(wǎng)絡(luò)的信號(hào)不好,重新嘗試上述安裝命令
2.若是重新嘗試仍報(bào)錯(cuò),更換下載源

vim ~/.condarc ##進(jìn)入conda的配置文件

更換成清華的源,并將- defaults此選項(xiàng)進(jìn)行移除;再重新嘗試安裝命令

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true

查看下載源(鏡像)

conda config --get channels

conda下載

wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh
(可以給其添加執(zhí)行權(quán)限:chmod 777 Miniconda3-py39_4.9.2-Linux-x86_64.sh)
安裝
bash Miniconda3-py39_4.9.2-Linux-x86_64.sh

按照提示按回車鍵ENTER或者是yes;
在選擇安裝到的目錄時(shí),可以指定你想要安裝的目錄(/data/mahuizhen/01-biosoft/miniconda3)
在詢問(wèn)是否將miniconda添加到環(huán)境變量時(shí),輸入yes將自動(dòng)添加到環(huán)境變量中,若是按回車鍵ENTER,則不會(huì)自動(dòng)添加到環(huán)境變量中,后面需要自己手動(dòng)添加;


# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/data/mahuizhen/01-biosoft/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/data/mahuizhen/01-biosoft/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/data/mahuizhen/01-biosoft/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/data/mahuizhen/01-biosoft/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

不管是自動(dòng)添加的環(huán)境變量還是手動(dòng)添加的環(huán)境變量,都需要source ~/.bashrc
這樣的話,才能用conda代替/data/mahuizhen/01-biosoft/miniconda3/bin/conda

conda -V 可以用其進(jìn)行測(cè)試。

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sh Miniconda3-latest-Linux-x86_64.sh

按照提示按回車鍵ENTER或者是yes;
在選擇安裝到的目錄時(shí),可以指定你想要安裝的目錄(/data/mahuizhen/01-biosoft/miniconda3)
在詢問(wèn)是否將miniconda添加到環(huán)境變量時(shí),輸入yes將自動(dòng)添加到環(huán)境變量中,若是按回車鍵ENTER,則不會(huì)自動(dòng)添加到環(huán)境變量中,后面需要自己手動(dòng)添加;
不管是自動(dòng)添加的環(huán)境變量還是手動(dòng)添加的環(huán)境變量,都需要source ~/.bashrc

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容