一、下载和安装:
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: