Creating a new Conda environment
Start your free 7-days trial now!
Creating new environment
To create a Conda environment, run the following in Terminal:
$ conda create --name my_env python
Here, we are naming our Conda environment
my_env, and configuring the environment for Python development.
Note the following:
if an environment called
my_envexists, then it would ask you whether or not you want to overwrite it.
Specifying Python version
By default, the new Conda environment will use the same version of Python as the base environment. We can specify which version to use by:
$ conda create --name my_env python=3.8
Specifying which libraries to include
By default, new Conda environments come with the core libraries such as
openssl. To include other packages such as
$ conda create --name my_env python flask
You can actually remove python here since
flask obviously depends on
python, and so Conda will also assume Python automatically.
As we've done previously, we can also specify which version of the library we wish to include:
$ conda create --name my_env python flask=1.1.1
Location of new environment
When you run the
create command, the path of the new environment should be shown on screen. In our case, the path is as follows:
environment location: /Users/SkyTowner/opt/anaconda3/envs/my_env
We see that Conda places our environment into a directory called
envs. You can specify the location by adding the
$ conda create --prefix /path/of/new/environment
Activating the environment
See a list of environments
To see all your Conda environments:
$ conda info --envs# conda environments:#base * /Users/SkyTowner/opt/anaconda3my_env /Users/SkyTowner/opt/anaconda3/envs/my_env
* indicates that
base is the currently active environment.
Activating the environment
To activate the Conda environment:
$ conda activate my_env
After you run the command, you should see
(my_env) appended at the front:
(my_env) Macbook:~ SkyTowner$
Deactivating the environment
To deactivate the Conda environment:
$ conda deactivate my_env
This brings us back to the
Installing new packages within the new environment
With the newly created environment active, call
conda install to install a new package:
(my_env) MacBook:~ SkyTowner$ conda install jsonpath## Package Plan ##environment location: /Users/TraverseTowner/opt/anaconda3/envs/my_env...
Since we're in
my_env, Conda installs the package
jsonpath under the
my_env directory. In our case,
jsonpath is installed in the following directory by default:
Note that if you did not have an environment active, that is, if you were in the
base environment, new packages would be installed in the
pkgs directory instead.