当前位置:网站首页>CONDA create use virtual environment

CONDA create use virtual environment

2022-06-12 06:17:00 Caicaicaicaicaicai

conda Creating and using virtual environments

Common commands

conda list   # See which packages are installed 
conda env list  or  conda info -e  See what virtual environments exist today  
conda upadte conda  Check to update the current conda

The role of virtual environment

 If it's on a computer ,  Want to develop multiple different projects ,  You need to use different versions of the same package ,  If you use the above command ,  Install or update in the same directory ,  The new version will override the previous version ,  Other projects won't work .  Solution  :  A virtual environment   effect  :  The virtual environment can build independent python Running environment ,  The running environment of a single project does not affect other projects .

Creating a virtual environment

1. establish

 conda create -n xxx python=3.8  #xxx Name the virtual environment you want to create 

2. Use activation ( Or switch different python edition ) Virtual environment for

python --version  #  You can check the current python Version of 
Linux:  source activate your_env_name( Virtual environment name )
Windows: activate your_env_name( Virtual environment name )

3. Install additional packages in the virtual environment

conda install -n your_env_name [package]
 Or use after activating the environment :
pip install [package]

4. Shut down the virtual environment

Linux: source deactivate
Windows: deactivate

5. Delete virtual environment

conda remove -n your_env_name( Virtual environment name ) --all
conda remove --name your_env_name  package_name  #  Delete a package in the environment 

##6. Rename the virtual environment

  1.  Clone the existing one into a new environment 
conda create -n new_env --clone old_env
  2.  Delete the original virtual environment 
conda remove -n old_env --all
原网站

版权声明
本文为[Caicaicaicaicaicai]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010611281569.html