Create and remove virtual environment by Anaconda
2024.2.16
2017.1.6
You can create virtual environment and execute Python program in it if you use Anaconda. It makes it easy to change Python version and manage packages.
Create environment
With name
$ conda create -n myenv
Create the virtual environment as "myenv". In this case, install Python of the latest version.
Create the virtual environment as "myenv". This will install the latest version of Python.
Specify Python version
$ conda create -n myenv python=3.7
Install Python 3.6 with the option Python=3.6
.
Specify the packages
If you specify the packages, you can install these when creating the environment.
$ conda create -n myenv matplotlib
You can specify the version of the package, such as matplotlib=3.0.0
.
$ conda create -n myenv python=3.7 matplotlib=3.0.0
Remove the environment
$ conda remove -n myenv --all
Show the list of the environment
$ conda-env list
The conda
command also displays the list.
$ conda info --envs
Switch the environment
Activate
$ conda activate myenv
Deactivate
(myenv) $ conda deactivate