{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "install:kernel_install",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "seealso",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "seealso "
                }
              ]
            },
            {
              "__type": "DefList",
              "__tag": 4033,
              "children": [
                {
                  "__type": "DefListItem",
                  "__tag": 4037,
                  "dt": {
                    "__type": "Paragraph",
                    "__tag": 4045,
                    "children": [
                      {
                        "__type": "InlineRole",
                        "__tag": 4003,
                        "value": "Installing Jupyter <jupyter:install>",
                        "domain": null,
                        "role": "ref",
                        "inventory": null
                      }
                    ]
                  },
                  "dd": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "The IPython kernel is the Python execution backend for Jupyter."
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The Jupyter Notebook and other frontends automatically ensure that the IPython kernel is available. However, if you want to use a kernel with a different version of Python, or in a virtualenv or conda environment, you'll need to install that manually."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Installing the IPython kernel"
        }
      ],
      "level": 0,
      "target": "kernel_install"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If you're running Jupyter on Python 3, you can set up a Python 2 kernel after checking your version of pip is greater than 9.0      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "python2 -m pip --version",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Then install with       "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "python2 -m pip install ipykernel\npython2 -m ipykernel install --user",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Or using conda, create a Python 2 environment      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "conda create -n ipykernel_py2 python=2 ipykernel\nsource activate ipykernel_py2    # On Windows, remove the word 'source'\npython -m ipykernel install --user",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "IPython 6.0 stopped support for Python 2, so installing IPython on Python 2 will give you an older version (5.x series)."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If you're running Jupyter on Python 2 and want to set up a Python 3 kernel, follow the same steps, replacing "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "3"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The last command installs a "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "kernel spec <jupyterclient:kernelspecs>",
              "domain": null,
              "role": "ref",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " file for the current python installation. Kernel spec files are JSON files, which can be viewed and changed with a normal text editor."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Kernels for Python 2 and 3"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If you want to have multiple IPython kernels for different virtualenvs or conda environments, you will need to specify unique names for the kernelspecs."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Make sure you have ipykernel installed in your environment. If you are using "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pip"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to install "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "ipykernel"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " in a conda env, make sure "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pip"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is installed:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "source activate myenv\nconda install pip\nconda install ipykernel # or pip install ipykernel",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For example, using conda environments, install a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "Python (myenv)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " Kernel in a first environment:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "source activate myenv\npython -m ipykernel install --user --name myenv --display-name \"Python (myenv)\"",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "And in a second environment, after making sure ipykernel is installed in it:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "source activate other-env\npython -m ipykernel install --user --name other-env --display-name \"Python (other-env)\"",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "--name"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " value is used by Jupyter internally. These commands will overwrite any existing kernel with the same name. "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "--display-name"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is what you see in the notebook menus."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Using virtualenv or conda envs, you can make your IPython kernel in one env available to Jupyter in a different env. To do so, run ipykernel install from the kernel's env, with --prefix pointing to the Jupyter env:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "/path/to/kernel/env/bin/python -m ipykernel install --prefix=/path/to/jupyter/env --name 'python-my-env'",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Note that this command will create a new configuration for the kernel in one of the preferred location (see "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "jupyter --paths"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " command for more details):"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "system-wide (e.g. /usr/local/share),"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "in Jupyter's env (sys.prefix/share),"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "per-user (~/.local/share or ~/Library/share)"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If you want to edit the kernelspec before installing it, you can do so in two steps. First, ask IPython to write its spec to a temporary location:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "ipython kernel install --prefix /tmp",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "edit the files in /tmp/share/jupyter/kernels/python3 to your liking, then when you are ready, tell Jupyter to install it (this will copy the files into a place Jupyter will look):"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "jupyter kernelspec install /tmp/share/jupyter/kernels/python3",
          "execution_status": null,
          "out": ""
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Kernels for different environments"
        }
      ],
      "level": 1,
      "target": "multiple_kernel_install"
    }
  ],
  "local_refs": []
}