Add a conda environment

This page describes how to add a conda environment to yourVertex AI Workbench instance.

Overview

When you add a conda environment toyour Vertex AI Workbench instance, it appears as akernelin your instance's JupyterLab interface.

You might add a conda environment to your Vertex AI Workbench instanceto use kernels that aren't available in Vertex AI Workbench instances.For example, you can add conda environments for R and Apache Beam. Or youcan add conda environments for specific earlier versions of the availableframeworks, such as TensorFlow, PyTorch, or Python.

Before you begin

If you haven't already,createa Vertex AI Workbench instance.

Open JupyterLab

  1. In the Google Cloud console, go to theInstances page.

    Go to Instances

  2. Next to your Vertex AI Workbench instance's name,clickOpen JupyterLab.

    Your Vertex AI Workbench instance opens JupyterLab.

Add a conda environment

You can add a conda environment by entering commands in your instance'sJupyterLab terminal.

  1. In JupyterLab,selectFile > New > Terminal.

  2. In theTerminal window, enter the following commands:

    #Createsacondaenvironment.condacreate-nCONDA_ENVIRONMENT_NAME-ycondaactivateCONDA_ENVIRONMENT_NAME#Installpackagesusingapiplocaltothecondaenvironment.condainstallpippipinstallPACKAGEpipinstallipykernel#Addsthecondakernel.DL_ANACONDA_ENV_HOME="${DL_ANACONDA_HOME}/envs/CONDA_ENVIRONMENT_NAME"python-mipykernelinstall--prefix"${DL_ANACONDA_ENV_HOME}"--nameCONDA_ENVIRONMENT_NAME--display-nameKERNEL_DISPLAY_NAME

    Replace the following:

    • CONDA_ENVIRONMENT_NAME: your choice ofname for the environment
    • PACKAGE: the package that you want to install
    • KERNEL_DISPLAY_NAME: the display name forthe tile of the kernel in the JupyterLab interface
  3. A default kernel can be created when installing to a givenconda environment. You can remove the default kernel with thefollowing command:

    rm -rf "/opt/micromamba/envs/CONDA_ENVIRONMENT_NAME/share/jupyter/kernels/python3
  4. To see your new kernel, do the following:

    1. Refresh the page.

    2. SelectFile > New Launcher.

    The kernel is listed among the others in theLauncher window.

By default, conda might use pip packages in the systempip folder(for example,/usr/bin/pip). Runningconda install pip ensures thatthe setup uses a pip local to the environment.

Example installation: R Essentials

The following example installs R Essentials in a conda environment namedr.

conda create -n rconda activate rconda install -c r r-essentials

Example installation: pip package

The following example installs pip packages from arequirements.txt file.

condacreate-nmyenvcondaactivatemyenvcondainstallpippipinstall-rrequirements.txtpipinstallipykernelDL_ANACONDA_ENV_HOME="${DL_ANACONDA_HOME}/envs/myenv"python-mipykernelinstall--prefix"${DL_ANACONDA_ENV_HOME}"--namemyenv--display-namemyenv

Troubleshoot

To diagnose and resolve issues related to adding a conda environment,seeTroubleshootingVertex AI Workbench.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.