admin 管理员组

文章数量: 1184232

在Windows下,为Jupyter创建新的kernel

目录

  • 创建环境
  • 激活环境以及安装必要的包
  • 创建新的kernel
  • Jupyter其他操作

1.创建环境

  • 打开Anaconda Prompt
  • 输入以下代码创建环境
(D:\Users\拾夕\Anaconda3) C:\Users\拾夕>conda create -n KernelForJupyter python=3.6
  • 得到以下结果
The following NEW packages will be INSTALLED:

    certifi:        2016.2.28-py36_0 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
    pip:            9.0.1-py36_1     https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
    python:         3.6.2-0          https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
    setuptools:     36.4.0-py36_1    https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
    vc:             14-0             https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
    vs2015_runtime: 14.0.25420-0     https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
    wheel:          0.29.0-py36_0    https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
    wincertstore:   0.2-py36_0       https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free

Proceed ([y]/n)? y

Linking packages ...
[      COMPLETE      ]|##################################################| 100%
#
# To activate this environment, use:
# > activate KernelForJupyter
#
# To deactivate this environment, use:
# > deactivate KernelForJupyter
#
# * for power-users using bash, you must source
#

2.激活环境以及安装必要的包

  • 输入以下代码激活环境
(D:\Users\拾夕\Anaconda3) C:\Users\拾夕> activate KernelForJupyter
  • 安装 ipykernel
(KernelForJupyter) C:\Users\拾夕>conda install ipykernel

3.创建新的kernel

  • 输入以下代码创建新的kernel
(KernelForJupyter) C:\Users\拾夕>python -m ipykernel install --name NewKernel
Installed kernelspec NewKernel in C:\ProgramData\jupyter\kernels\newkernel
  • 然后就可以在Jupyter中使用了

4.Jupyter其他操作

  • 我们通过以下代码查看juypter kernel的其他命令
(KernelForJupyter) C:\Users\拾夕>jupyter kernelspec --help
Manage Jupyter kernel specifications.

Subcommands
-----------

Subcommands are launched as `jupyter kernelspec cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter kernelspec cmd -h`.

list
    List installed kernel specifications.
install
    Install a kernel specification directory.
uninstall
    Alias for remove
remove
    Remove one or more Jupyter kernelspecs by name.
install-self
    [DEPRECATED] Install the IPython kernel spec directory for this Python
  • 例如我们可以通过以下指令查看当前环境下的kernel
(KernelForJupyter) C:\Users\拾夕>jupyter kernelspec list
Available kernels:
  python3      D:\Users\拾夕\Anaconda3\envs\KernelForJupyter\share\jupyter\kernels\python3
  newkernel    C:\ProgramData\jupyter\kernels\newkernel

本文标签: 工具 jupyter Kernel Windows