Anaconda Notebooks is a hosted JupyterLab service that enables you to run JupyterLab notebooks online while simultaneously taking advantage of conda’s robust environment management tools. To execute code in a conda environment in Anaconda Notebooks, you must associate each environment with a language-specific kernel.

Environments and kernels

What is an environment?

An environment is a folder or directory that contains a specific collection of conda packages and their dependencies.

Working in separate environments allows you to maintain and run packages without interference from other collections of packages. For example, you may require separate conda environments to maintain distinct versions of Python based on distinct package dependencies.

What is a kernel?

A kernel is a programming-language-specific process that interprets your code, runs it, and gives you the results. In Jupyter Notebooks, kernels allow users to run code in cells and receive immediate output. For example, ipykernel enables interactive computing in Python, and r-irkernel enables the same for R.

In order for an environment to be able to run code for a notebook, it must contain a kernel package; otherwise, the environment will not be recognized by JupyterLab as an available kernel. For this reason, the default environments available in Anaconda Notebooks already contain the ipykernel package.

To add a kernel package to a custom environment, see creating custom environment.

Using default environments

Custom environments often use large amounts of your limited Anaconda Notebooks storage space. Because of this, Anaconda provides a number of read-only default environments that contain all the packages from the latest release of Anaconda Distribution.

The default environment naming convention is typically anaconda-<YEAR>.<MONTH>-py<PYTHON_VERSION>, which maps to Anaconda Distribution releases:

Environment NameStatusDescription
anaconda-2024.02-py10LiveLatest Anaconda Packages (stable & recommended)
anaconda-ai-2024.04-py10LiveLatest Anaconda Packages + AI Packages

To see a list of available environments:

conda info --envs

To see a list of packages in your current environment:

conda list

Creating custom environments

If you need a specific set of packages that are not included in one of our default environments, you can create your own environment to customize to your needs.

Custom environments are stored using your dedicated, persistent Anaconda Notebooks storage. This ensures the custom environment will be available after the current session. Custom environments use your personal storage space and can easily get quite large, so only include the packages you need.

To create a new environment with an associated kernel:

  1. Open a terminal from the Launcher, which you can access by clicking the blue plus in the top-left corner.

  2. Create a conda environment with an associated kernel by running the following command:

    
    # Replace <ENV_NAME> with a new name for your environment
    
    # Replace <PACKAGE> with the name of a package you want to install in your environment
    
    # Replace <KERNEL_PACKAGE> with the appropriate kernel package
    
    conda create --name <ENV_NAME> <PACKAGE> <KERNEL_PACKAGE>
    
    
    • To create a Python kernel, replace <KERNEL\_PACKAGE> with ipykernel.
    • To create an R kernel, replace <KERNEL\_PACKAGE> with r-irkernel.

For more information about creating conda environments, see the official conda docs.

It might take a minute for your environment to be created and available for use. You might need to close and reopen your active notebook or refresh the browser for your new environment to appear.

Activating environments

There are a few locations from which you can activate your environment:

Run the following within Anaconda Notebooks:

# Replace <ENV_NAME> with the name of your environment

conda activate <ENV_NAME>

Installing additional packages

Even after you’ve created an environment, you can continue to add packages as needed. To install additional packages in your environment, run the following command:

# Replace <PACKAGE> with the name of a package you want to install

conda install <PACKAGE>

Deactivating environments

It is best practice to deactivate your environment when you are finished working in it. To deactivate your active environment, run the following command:

conda deactivate