conda可以切換python版本

微信 smartcat9999
$ wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh
$ sh Miniconda3-py311_23.5.2-0-Linux-x86_64.sh
Welcome to Miniconda3 py311_23.5.2-0
In order to continue the installation process, please review the license agreement.
Please, press ENTER to continue
\>>>
Do you accept the license terms? [yes|no]
[no] >>> yes
Press ENTER to confirm the location
Press CTRL-C to abort the installation
Or specify a different location below
Unpacking payload ...
Installing base environment...
Downloading and Extracting Packages
Downloading and Extracting Packages
Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no]
[no] >>> yes
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
Thank you for installing Miniconda3! (base)
$ conda --version
conda 23.5.2
$ conda install conda=23.7.2
Collecting package metadata (current_repodata.json): done
Solving environment: done
Proceed ([y]/n)? y
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
$ cat .condarc
channels:
defaults
show_channel_urls: true
default_channels:
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
$ conda create --name python310 python=3.10
Collecting package metadata (current_repodata.json): done
Solving environment: done
Proceed ([y]/n)? y
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
$ conda create --name python39 python=3.9
Collecting package metadata (current_repodata.json): done
Solving environment: done
Proceed ([y]/n)? y
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base)$ conda activate python39
(python39) $ python -V
Python 3.9.17
$ conda deactivate
(base)$ conda activate python310
(python310) $ python -V
Python 3.10.12