jupyter notebook 添加java核心

参考:https://github.com/SpencerPark/IJava

一、环境(java核心需要jdk9以上支持,可在https://www.oracle.com/java/technologies/javase-jdk15-downloads.html下载)

已安装java,版本如下:

[root@localhost ~]# java -version
java version "15.0.1" 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

二、java核心下载:

(python) [root@localhost ~]# wget https://github.com/SpencerPark/IJava/releases/download/v1.2.0/ijava-1.2.0.zip

三、安装过程

1、解压:

(python) [root@localhost ~]# unzip ijava-1.2.0.zip

生成java目录和install.py安装文件

2、执行安装:

(python) [root@localhost ~]# python install.py --sys-prefix

install.py:164: DeprecationWarning: replace is ignored. Installing a kernelspec always replaces an existing installation
  install_dest = KernelSpecManager().install_kernel_spec(
Installed java kernel into "/root/miniconda3/envs/python/share/jupyter/kernels/java"

3、查看安装核心情况

(python) [root@localhost ~]# jupyter kernelspec list
Available kernels:
  java       /root/miniconda3/envs/python/share/jupyter/kernels/java
  python3    /root/miniconda3/envs/python/share/jupyter/kernels/python3

4、移除核心

(python) [root@localhost ~]# jupyter kernelspec remove java

5、模拟运行核心

(python) [root@localhost ~]# jupyter console --kernel=python3         #模拟运行python3核心
Jupyter console 6.2.0

Python 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 18:01:20)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

(python) [root@localhost ~]# jupyter console --kernel=java                  #模拟运行java核心
Jupyter console 6.2.0

Python 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 18:01:20)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

原文地址:https://www.cnblogs.com/sfccl/p/13957080.html