HOW TO

Install a new kernel in Jupyter Notebook using a specific Python environment

Last Published: April 25, 2020

Summary

Instead of running a separate instance of Jupyter Notebook for different Python environments, it is possible to install a kernel with a specific Python environment in Jupyter Notebook. The environment is then configured when creating a new notebook.

Procedure

To install a kernel with a specific Python environment in Jupyter Notebook, follow the steps described below:

  1. Run the Python Command Prompt as an administrator.
Note:
The Python Command Prompt window opens with the active default Python environment.
  1. In the Python Command Prompt window, insert the following command:
python -m ipykernel install --user --name <python environment> --display-name "Python (<python environment>)"
  1. Press Enter on the keyboard, and the following response is returned:
Installed kernelspec <python environment> in C:\Users\<user>\AppData\Roaming\jupyter\kernels\<python environment>

The image below shows the command and response in the Python Command Prompt window. The name of the Python environment used in this example is arcgispro-py3-clone1.

Python Command Prompt window
  1. Run Jupyter Notebook from the default Python environment.
  2. In the Files tab, click New.
Jupyter Notebook
The new Python environment is listed as a new kernel.

Alternatively, manually create a new kernel with a specific Python environment in the kernels folder.

  1. Navigate to the following location:
C:\Users\<Username>\AppData\Roaming\jupyter\kernels
  1. Create a kernel JSON file.
    1. Using Notepad++, insert the following JSON code:
{
"argv": [
"C:\Users\<user>\AppData\Local\ESRI\conda\envs\<python environment>\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python (<python environment>)",
"language": "python"
}
  1. In the Notepad++ window, click File > Save As... .
  2. In the box next to File name, insert kernel.json.
  3. Click the box next to Save as type, and select All Files.
  4. Click Save.
Save the kernel JSON file

Article ID: 000019210

Software:
  • ArcGIS Pro
  • ArcGIS API for Python

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options