[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-23 UTC。"],[],[],null,["# Add a conda environment to a Vertex AI Workbench instance\n\nAdd a conda environment\n=======================\n\nThis page describes how to add a conda environment to your\nVertex AI Workbench instance.\n\nOverview\n--------\n\nWhen you add a conda environment to\nyour Vertex AI Workbench instance, it appears as a\n[kernel](https://jupyterlab.readthedocs.io/en/stable/user/documents_kernels.html)\nin your instance's JupyterLab interface.\n\nYou might add a conda environment to your Vertex AI Workbench instance\nto use kernels that aren't available in Vertex AI Workbench instances.\nFor example, you can add conda environments for R and Apache Beam. Or you\ncan add conda environments for specific older versions of the available\nframeworks, such as TensorFlow, PyTorch, or Python.\n\nBefore you begin\n----------------\n\nIf you haven't already,\n[create\na Vertex AI Workbench instance](/vertex-ai/docs/workbench/instances/create-console-quickstart).\n\nOpen JupyterLab\n---------------\n\n1. In the Google Cloud console, go to the **Instances** page.\n\n [Go to Instances](https://console.cloud.google.com/vertex-ai/workbench/instances)\n2. Next to your Vertex AI Workbench instance's name,\n click **Open JupyterLab**.\n\n Your Vertex AI Workbench instance opens JupyterLab.\n\nAdd a conda environment\n-----------------------\n\nYou can add a conda environment by entering commands in your instance's\nJupyterLab terminal.\n\n1. In JupyterLab,\n select **File \\\u003e New \\\u003e Terminal**.\n\n2. In the **Terminal** window, enter the following commands:\n\n ```genshi\n # Creates a conda environment.\n conda create -n CONDA_ENVIRONMENT_NAME -y\n conda activate CONDA_ENVIRONMENT_NAME\n\n # Install packages using a pip local to the conda environment.\n conda install pip\n pip install PACKAGE\n\n # Adds the conda kernel.\n DL_ANACONDA_ENV_HOME=\"${DL_ANACONDA_HOME}/envs/CONDA_ENVIRONMENT_NAME\"\n python -m ipykernel install --prefix \"${DL_ANACONDA_ENV_HOME}\" --name CONDA_ENVIRONMENT_NAME --display-name KERNEL_DISPLAY_NAME\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCONDA_ENVIRONMENT_NAME\u003c/var\u003e: your choice of name for the environment\n - \u003cvar translate=\"no\"\u003ePACKAGE\u003c/var\u003e: the package that you want to install\n - \u003cvar translate=\"no\"\u003eKERNEL_DISPLAY_NAME\u003c/var\u003e: the display name for the tile of the kernel in the JupyterLab interface\n3. A default kernel can be created when installing to a given\n conda environment. You can remove the default kernel with the\n following command:\n\n ```scdoc\n rm -rf \"/opt/micromamba/envs/CONDA_ENVIRONMENT_NAME/share/jupyter/kernels/python3\n ```\n4. To see your new kernel, do the following:\n\n 1. Refresh the page.\n\n 2. Select **File \\\u003e New Launcher**.\n\n The kernel is listed among the others in the **Launcher** window.\n\nBy default, conda might use pip packages in the system `pip` folder\n(for example, `/usr/bin/pip`). Running `conda install pip` ensures that\nthe setup uses a pip local to the environment.\n\nExample installation: R Essentials\n----------------------------------\n\nThe following example installs R Essentials in a conda environment named `r`. \n\n```text\nconda create -n r\nconda activate r\nconda install -c r r-essentials\n```\n\nExample installation: pip package\n---------------------------------\n\nThe following example installs pip packages from a `requirements.txt` file. \n\n```genshi\nconda create -n myenv\nconda activate myenv\nconda install pip\npip install -r requirements.txt\nDL_ANACONDA_ENV_HOME=\"${DL_ANACONDA_HOME}/envs/myenv\"\npython -m ipykernel install --prefix \"${DL_ANACONDA_ENV_HOME}\" --name myenv --display-name myenv\n```\n\nTroubleshoot\n------------\n\nTo diagnose and resolve issues related to adding a conda environment,\nsee [Troubleshooting\nVertex AI Workbench](/vertex-ai/docs/general/troubleshooting-workbench#pip-packages-missing-instances).\n\nWhat's next\n-----------\n\n- Learn more about [conda](https://docs.conda.io/en/latest/).\n\n- To modify your conda environment, see [Manage your conda\n environment](/vertex-ai/docs/workbench/instances/manage-environment)."]]