[Windows] minicanda installation and environment configuration

Posted by Eminem on Sun, 19 Sep 2021 12:50:24 +0200

The installation of Miniconda is mainly divided into the following aspects:

Miniconda is a small Python environment management tool. The installation package is only about 50M. Its installation program includes conda package manager and python. Once miniconda is installed, you can use the conda command to install any other software toolkit, create an environment, and so on.

Popular understanding: Miniconda is an environment management tool, which can install the software packages required by users, and there is no impact between various software packages.

1, Download and installation of Miniconda
If Miniconda downloads directly from foreign websites, the download is relatively slow. You can choose the open source mirror station of Tsinghua University miniconda open source mirror station of Tsinghua University Download, so the download speed is faster. (or you can download it on Anaconda's official website, which is slow)

1. The installation process is relatively simple, but it should be noted that "add to environment variable" should be checked during installation.
2. After installation, you can enter the Windows command line with WIN+R and enter conda to check whether the installation is successful.
3. After installation, enter the command line and enter the following command to initialize conda

// initialization
conda init cmd.exe

4. Key points: after installation, if the software package needs to be installed in conda environment, the download speed is also very slow. At this time, it can also be solved by mirroring the website. The specific operation steps are as follows:

Because Windows system users cannot directly create files starting with '.', such as'. temp '. Therefore, the following commands must be executed on the command line.

// Execute on the Windows command line
conda config --set show_channel_urls yes
// Execute on the Windows command line

Observe whether the. condarc file exists. If it exists, find the Administrator or the folder "name displayed when your computer starts" in the C:\User directory, then open the. condarc file with Notepad, delete the contents, and copy all the following codes to save.

  - defaults
show_channel_urls: true
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

After copying and saving, execute the following commands on the Windows command line:

// Clear the index cache to ensure that the index provided by the mirror station is used
conda clean -i

2, Some common commands for viewing related information in conda
1. View current environment information

// View current environment information
conda info

2. View all virtual environments that have been created

//View all virtual environments that have been created
conda info -e

3. Switch (activate) virtual environment

// Switch to name virtual environment
conda activate name
//exmple: switch to Python 3.7 virtual environment
conda activate python3.7

4. Shut down the virtual environment

// Close to name virtual environment
conda deactivate name
//exmple: close the virtual environment of Python 3.7
conda deactivate python3.7

5. Change the number of digits of the computer platform (32 or 64)

// Switch to 32-bit
//Switch to 64 bit

6. Create a virtual environment

// Create a python 3.8 virtual environment named xxx, where xxx indicates the name given to the environment, and the version number of the installation environment is indicated after the equal sign
conda create -n xxx python=3.8

7. Install the module in the environment

// When installing modules in an environment, you must first activate the environment and then install in the environment
conda install Environment name

8. Delete environment

// Delete an environment
conda remove -n Environment name --all

9. List packages in conda

// List packages
conda list

Topics: Python Windows