Show More
@@ -1,106 +1,106 b'' | |||
|
1 | 1 | .. _kernel_install: |
|
2 | 2 | |
|
3 | 3 | Installing the IPython kernel |
|
4 | 4 | ============================= |
|
5 | 5 | |
|
6 | 6 | .. seealso:: |
|
7 | 7 | |
|
8 | 8 | :ref:`Installing Jupyter <jupyter:install>` |
|
9 | 9 | The IPython kernel is the Python execution backend for Jupyter. |
|
10 | 10 | |
|
11 | 11 | The Jupyter Notebook and other frontends automatically ensure that the IPython kernel is available. |
|
12 | 12 | However, if you want to use a kernel with a different version of Python, or in a virtualenv or conda environment, |
|
13 | 13 | you'll need to install that manually. |
|
14 | 14 | |
|
15 | 15 | Kernels for Python 2 and 3 |
|
16 | 16 | -------------------------- |
|
17 | 17 | |
|
18 | 18 | If you're running Jupyter on Python 3, you can set up a Python 2 kernel after |
|
19 | 19 | checking your version of pip is greater than 9.0:: |
|
20 | 20 | |
|
21 | 21 | python2 -m pip --version |
|
22 | 22 | |
|
23 | 23 | Then install with :: |
|
24 | 24 | |
|
25 | 25 | python2 -m pip install ipykernel |
|
26 | 26 | python2 -m ipykernel install --user |
|
27 | 27 | |
|
28 | 28 | Or using conda, create a Python 2 environment:: |
|
29 | 29 | |
|
30 | 30 | conda create -n ipykernel_py2 python=2 ipykernel |
|
31 | 31 | source activate ipykernel_py2 # On Windows, remove the word 'source' |
|
32 | 32 | python -m ipykernel install --user |
|
33 | 33 | |
|
34 | 34 | .. note:: |
|
35 | 35 | |
|
36 | 36 | IPython 6.0 stopped support for Python 2, so |
|
37 | 37 | installing IPython on Python 2 will give you an older version (5.x series). |
|
38 | 38 | |
|
39 | 39 | If you're running Jupyter on Python 2 and want to set up a Python 3 kernel, |
|
40 | 40 | follow the same steps, replacing ``2`` with ``3``. |
|
41 | 41 | |
|
42 | 42 | The last command installs a :ref:`kernel spec <jupyterclient:kernelspecs>` file |
|
43 | 43 | for the current python installation. Kernel spec files are JSON files, which |
|
44 | 44 | can be viewed and changed with a normal text editor. |
|
45 | 45 | |
|
46 | 46 | .. _multiple_kernel_install: |
|
47 | 47 | |
|
48 | 48 | Kernels for different environments |
|
49 | 49 | ---------------------------------- |
|
50 | 50 | |
|
51 | 51 | If you want to have multiple IPython kernels for different virtualenvs or conda |
|
52 | 52 | environments, you will need to specify unique names for the kernelspecs. |
|
53 | 53 | |
|
54 | 54 | Make sure you have ipykernel installed in your environement. If you are using |
|
55 | 55 | ``pip`` to install ``ipykernel`` in a conda env, make sure ``pip`` is |
|
56 |
installed: |
|
|
56 | installed: | |
|
57 | 57 | |
|
58 | 58 | .. sourcecode:: bash |
|
59 | 59 | |
|
60 | 60 | source activate myenv |
|
61 | 61 | conda install pip |
|
62 | 62 | conda install ipykernel # or pip install ipykernel |
|
63 | 63 | |
|
64 | 64 | For example, using conda environments, install a ``Python (myenv)`` Kernel in a first |
|
65 | 65 | environment: |
|
66 | 66 | |
|
67 | 67 | .. sourcecode:: bash |
|
68 | 68 | |
|
69 | 69 | source activate myenv |
|
70 | 70 | python -m ipykernel install --user --name myenv --display-name "Python (myenv)" |
|
71 | 71 | |
|
72 | 72 | And in a second environment, after making sure ipykernel is installed in it: |
|
73 | 73 | |
|
74 | 74 | .. sourcecode:: bash |
|
75 | 75 | |
|
76 | 76 | source activate other-env |
|
77 | 77 | python -m ipykernel install --user --name other-env --display-name "Python (other-env)" |
|
78 | 78 | |
|
79 | 79 | The ``--name`` value is used by Jupyter internally. These commands will overwrite |
|
80 | 80 | any existing kernel with the same name. ``--display-name`` is what you see in |
|
81 | 81 | the notebook menus. |
|
82 | 82 | |
|
83 | 83 | 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: |
|
84 | 84 | |
|
85 | 85 | .. sourcecode:: bash |
|
86 | 86 | |
|
87 | 87 | /path/to/kernel/env/bin/python -m ipykernel install --prefix=/path/to/jupyter/env --name 'python-my-env' |
|
88 | 88 | |
|
89 | 89 | Note that this command will create a new configuration for the kernel in one of the prefered location (see ``jupyter --paths`` command for more details): |
|
90 | 90 | |
|
91 | 91 | * system-wide (e.g. /usr/local/share), |
|
92 | 92 | * in Jupyter's env (sys.prefix/share), |
|
93 | 93 | * per-user (~/.local/share or ~/Library/share) |
|
94 | 94 | |
|
95 | 95 | If you want to edit the kernelspec before installing it, you can do so in two steps. |
|
96 | 96 | First, ask IPython to write its spec to a temporary location: |
|
97 | 97 | |
|
98 | 98 | .. sourcecode:: bash |
|
99 | 99 | |
|
100 | 100 | ipython kernel install --prefix /tmp |
|
101 | 101 | |
|
102 | 102 | 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): |
|
103 | 103 | |
|
104 | 104 | .. sourcecode:: bash |
|
105 | 105 | |
|
106 | 106 | jupyter kernelspec install /tmp/share/jupyter/kernels/python3 |
General Comments 0
You need to be logged in to leave comments.
Login now