How to do it...

  1. Start by opening a Terminal window and running the following commands:
conda update conda
conda update anaconda

These commands update both conda and Anaconda to the most recent versions. This is always recommended before creating a new environment.

  1. Next, run the following line to create a new environment named myenv:
conda create --name myenv
  1. You will be asked for confirmation and conda will then create the new environment. We now need to activate the new environment. For Linux and macOS, run the following command in the terminal:
source activate myenv
  1. In Windows, run the following:
activate myenv
  1. Notice that the command line changes to reflect the active environment, as shown in the following example:
(myenv) computer:~ username
  1. To confirm that the new environment was created, we can execute the following command:
conda info --envs
  1. This command now produces the following output:
# conda environments:
#
myenv * /Users/username/anaconda/envs/myenv
root /Users/username/anaconda

Notice that the currently active environment is marked with an asterisk.

  1. We can now install packages in the active environment without interfering with the original Python distribution. For example, to install the csvkit package, we use code in the following example:
conda install csvkit
  1. When you are done working in the environment, it is necessary to deactivate it. In Linux and macOS, this is done with the following command:
source deactivate
  1. In Windows, the command to do so is the following:
deactivate
  1. If you decide you don't need the myenv environment any longer, it can be deleted with the following command:
conda remove myenv --all

Note that you cannot remove the currently active environment.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset