Table of Contents of Series Articles
Article directory
Preface
Conda is a general-purpose package management system designed to build and manage software in any language and of any type. For example: package management is similar to the use of pip, and environment management allows users to easily install different versions of python and switch quickly.
Anaconda is a packaged collection, which is pre-installed with Conda, Python and a lot of installed tool packages, such as numpy, pandas, etc. It has many packages, scientific computing tools, etc., which is a combination of many commonly used and uncommon libraries. It's all installed for you.
Miniconda is a compact python environment management tool. The installation package is only about 50M. Its installation program includes the conda package manager and Python, as well as related necessary dependencies. For users with strict space requirements, Miniconda is a choose. It only contains the most basic things, and you have to install other libraries yourself.
The difference between Miniconda and Anaconda:
Miniconda is a lightweight version of Anaconda, including only Python and Conda, and their dependencies. The advantage of Miniconda is that it is small and fast, and users can select and install the packages they need.
Function angle: Anaconda = Miniconda
Size angle: Anaconda > Miniconda
Functional angle: Anaconda > Miniconda
1. Download and install Conda
1.Download
Download address: https://docs.conda.io/en/latest/miniconda.html
2.Installation
3. Configure domestic sources
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
2. Conda installs Python environment
1. Create a virtual environment
conda create --name <env_name> python=3.9
Check whether the environment is created successfully:
conda env list
2. Activate the virtual environment
activate <env_name>
3. Install Python library in virtual environment
conda install pytest
or
pip install pytest
3. Conda environment environment execution script
4. PyCharm configures Conda environment
File>Settings>Project>Python Interpreter>Add Interpreter>Conda Environment>Select Conda Executable>Use Existing Environment:
5. Conda migration environment
1. Method 1: Copy the environment
conda create --name <new_env_name> --clone <old_env_name>
2. Method 2: Export the environment package list
Export environment_name.yml file:
conda env export > environment.yml
Import the environment_name.yml file:
conda env create -f environment.yml
3. Method 3: Offline deployment
Install packaging tools:
conda install conda-pack
或
pip install conda-pack
Package the virtual environment:
conda pack -n <env_name>
Create a new environment directory:
mkdir <env_name>
Restore environment:
tar -zxvf <env_name>.tar.gz -C <env_name>
Note:
Conda-Pack packaging environment method is very useful when the target computer cannot connect to the Internet or the network is not smooth, and Conda's method of exporting environment.yml is very suitable for recreating environments between different platforms and operating systems.