Reprinted from commonly used commands in the conda environment
In different projects, conda is often needed to configure the environment, which can realize the random switching of different versions of python and libraries, and reduce a lot of unnecessary troubles. Some basic commands commonly used by conda are recorded here for subsequent queries
1. Query conda version
conda -V
2. Query all conda environments
conda info -e
3. Create a new conda environment
# conda create --name [环境名] python=[python版本]
conda create --name conda_name python=3.7.13
4. Enter the corresponding conda environment
# conda activate [环境名]
conda activate conda_name
5. Exit the current conda environment
conda deactivate
6. Add libraries to the conda environment
Take installing tensorflow-gpu as an example, the operation is similar to pip installation
conda install tensorflow-gpu==1.15.4
7. Delete the corresponding conda environment
When deleting an environment, exit from that environment first
# conda remove -n [环境名] --all
conda remove -n conda_name --all
8. clone environment
(a). Clone a new environment according to the environment name
# conda create -n [新环境名称] --clone [现有环境名称]
conda create -n new_name --clone conda_name
(b). Copy and generate a new environment according to the environment path.
If the existing environment path is C:\Python\Anaconda3\envs\huggingface, the new environment to be generated is named B, as in the following example:
# conda create -n [新环境名称] --clone [现有环境地址]
conda create -n new_name --clone C:\Python\Anaconda3\envs\huggingface
The location of the generated new environment is under the installation path of anaconda, as in the example, it is in the location of C:\Python\Anaconda3\envs