Anaconda creates and deletes virtual environment instructions

Use conda to create and delete virtual environment commands {\color{Red} use conda to create and delete virtual environment commands}Use con d a to create and delete virtual environment instructions

1. Create a virtual environment

Anaconda is a Python distribution. With it, you can create different virtual environments. For example, one environment requires Python3.7, and another environment requires python3.8. You can pass:

# 列举pip当前可以更新的所有安装包
conda create -name  环境名1号 python=3.7
conda create -name  环境名1号 python=3.9....

To achieve the purpose of multi-environment management
 

Second, view the virtual environment

conda info --env

 

3. Activate the virtual environment

conda activate env_1

For example:

conda create -name py37 python=3.7
activate
conda activate py37

Note, if cmd directly enters this command conda activate py37, it will not be able to enter, because you have to enter the base environment first. That is to activate first, then conda activate py37
 

4. Delete the virtual environment

method one:

# 第一步:首先退出环境
conda deactivate
 
# 第二步:查看虚拟环境列表,此时出现列表的同时还会显示其所在路径
conda env list
 
# 第三步:删除环境
conda env remove -p 要删除的虚拟环境路径

Method Two:

# 第一步:首先退出环境
conda deactivate
 
# 第二步:删除环境
conda remove -n  需要删除的环境名 --all

Another way to view the virtual environment path - prerequisite: still in this virtual environment

echo ${
    
    CONDA_PREFIX}

5. Delete the package in the virtual environment

conda remove --name $your_env_name $package_neme(包名)

Guess you like

Origin blog.csdn.net/weixin_49457347/article/details/126303886