一、下載和安裝:
1、下載:[root@localhost ~]# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
2、安裝:
[root@localhost ~]# chmod +x Miniconda3-latest-Linux-x86_64.sh
[root@localhost ~]# ./Miniconda3-latest-Linux-x86_64.sh
...
yaml pkgs/main/linux-64::yaml-0.1.7-had09818_2
zlib pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3
Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
[no] >>> yes
no change /root/miniconda3/condabin/conda
no change /root/miniconda3/bin/conda
no change /root/miniconda3/bin/conda-env
no change /root/miniconda3/bin/activate
no change /root/miniconda3/bin/deactivate
no change /root/miniconda3/etc/profile.d/conda.sh
no change /root/miniconda3/etc/fish/conf.d/conda.fish
no change /root/miniconda3/shell/condabin/Conda.psm1
no change /root/miniconda3/shell/condabin/conda-hook.ps1
no change /root/miniconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change /root/miniconda3/etc/profile.d/conda.csh
modified /root/.bashrc
==> For changes to take effect, close and re-open your current shell. <==
If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false #若是啟動時不需要激活miniconda的基礎環境,可設置auto_activate_base參數為false
Thank you for installing Miniconda3!
二、conda的使用
1、查看版本:
(base) [root@localhost ~]# conda --version
conda 4.8.3
2、添加清華鏡像倉庫:
(base) [root@localhost ~]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
(base) [root@localhost ~]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
(base) [root@localhost ~]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
(base) [root@localhost ~]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
(base) [root@localhost ~]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
(base) [root@localhost ~]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
3、查看下載源:
(base) [root@localhost ~]# conda config --show-sources
==> /root/.condarc <==
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- 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/
- defaults
4、設置搜索時顯示通道地址:
(base) [root@localhost ~]# conda config --set show_channel_urls yes
5、創建並激活一個環境:
(base) [root@localhost ~]# conda create --name python #創建名稱為python的環境
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.8.3
latest version: 4.8.5
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: /root/miniconda3/envs/python
Proceed ([y]/n)?
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate python
#
# To deactivate an active environment, use
#
# $ conda deactivate
python環境的安裝位置在:/root/miniconda3/envs/python
安裝環境並制定python版本的命令:conda create --name python python=3.6
(base) [root@localhost ~]# conda create --name python2 python=2.7 #安裝名稱為python2的版本號為2.7的python環境
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.8.3
latest version: 4.8.5
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: /root/miniconda3/envs/python2
added / updated specs:
- python=2.7
The following packages will be downloaded:
...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate python2
#
# To deactivate an active environment, use
#
# $ conda deactivate
激活python2環境:
(base) [root@localhost ~]# conda activate python2
列出所有環境:
(python2) [root@localhost ~]# conda info -e #或者 conda env list
# conda environments:
#
base /root/miniconda3
python /root/miniconda3/envs/python
python2 * /root/miniconda3/envs/python2
6、退出環境:
(python2) [root@localhost ~]# conda deactivate
7、移除python2下的軟件包zlib:
(base) [root@localhost ~]# conda remove -n python2 zlib
8、移除python2環境:
(base) [root@localhost ~]# conda remove -n python2 --all
Remove all packages in environment /root/miniconda3/envs/python2:
## Package Plan ##
environment location: /root/miniconda3/envs/python2
The following packages will be REMOVED:
_libgcc_mutex-0.1-conda_forge
...
zlib-1.2.11-h516909a_1009
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base) [root@localhost ~]#
或者:
(base) [root@localhost ~]# conda env remove -n python
Remove all packages in environment /root/miniconda3/envs/python:
9、設置開機不自動進入base環境
(python) [root@localhost ~]# conda config --describe #查看默認環境配置
...
# # auto_activate_base (bool)
# # Automatically activate the base environment during shell
# # initialization.
# #
# auto_activate_base: true
...
(python) [root@localhost ~]# conda config --set auto_activate_base false #配置為默認不進入base環境