Jupyterhub+Jupyter Kotlin Kernel安装与配置

Jupyterhub安装

请确认自己在root环境下进行后续安装操作。以及jupyterhub必须在root环境下运行,否则会有权限问题。

环境依赖

运行库
  • zlib
    yum install zlib-devel
  • _sqlite3
    yum install sqlite-devel
  • _ctype
    yum install libffi-devel
  • openssl
    yum install openssl-devel
python > 3.6

下载python到用户的根目录,解压后运行以下命令进行安装(以python3.9.1为例)

/home/username/Python-3.9.1/
./configure
make && make install
npm, nodejs

可以参照官网要求安装
https://nodejs.org/zh-cn/

添加环境变量
# 在/etc/profile.d/新建jupytersetup.sh
export NODE_HOME=/usr/local/node-v16.15.0-linux-x64
export PYTHON3_HOME=/usr/local/bin
export PATH=$PATH:$NODE_HOME/bin:$PYTHON3_HOME

然后执行 source jupytersetup.sh更新环境变量

安装jupyterhub

# conda
conda install -c conda-forge jupyterhub
conda install notebook

# pip, npm:
python3 -m pip install jupyterhub
npm install -g configurable-http-proxy

测试是否安装成功

jypyterhub -h
configurable-http-proxy -h

配置jupyterhub

在/etc/jupyterhub生成config文件

jupyterhub --generate-config -f /etc/jupyterhub/jupyterhub_config.py

建立一个新的账户

useradd jupyteradmin
passwd {密码}

在配置文件中添加如下配置,其中admin_users与password可以按自己需求修改

c.JupyterHub.ip = ''
c.JupyterHub.port = 
c.LocalAuthenticator.create_system_users = True
c.Authenticator.allowed_users = {'root'}
c.Authenticator.admin_users = {'root', 'jupyteradmin'}
c.DummyAuthenticator.password = "globalpwd"
c.JupyterHub.authenticator_class = 'jupyterhub.auth.DummyAuthenticator'

测试一下能否启动jupyterhub,使用以下命令启动jupyterhub

jupyterhub -f /etc/jupyterhub/jupyterhub_config.py

连接log中显示的网址http://ip:port查看页面,用户名为jupyteradmin, 密码为globalpwd。可以尝试启动server。然后即可点击连接此服务器。

此时会发现,通过网址连接到jupyterhub可以点击启动kernel但是会发现并不能进入用户界面,我们需要为jupyterhub安装jupyterlab前端。

安装jupyterlab前端

pip3 install jupyterlab

如果jupyterlab无法自动启动,可以尝试以下命令设置jupyterlab为jupyter的前端

jupyter serverextension enable --py jupyterlab --user

附:Kotlin支持: Kotlin-jupyter kernel

Jupyterhub不仅支持python,也可以通过安装插件的方式支持java以及kolin。这里以kotlin为例整理安装流程:

仓库地址: https://github.com/Kotlin/kotlin-jupyter

# install via pip
pip3 install kotlin-jupyter-kernel

安装完成后即可在jupyternotebook中看到kotlin kernel

运行过程中出现 Permision Denied 'java'.
解决方法:将Java转移到/opt/下,并重新设置JAVA_HOME。

cp -r $JAVA_HOME /opt/java-11

然后打开环境变量 vim /etc/profile,将 JAVA_HOMEJRE_HOME改为新的 /opt/java-xx.xx.xx。保存后执行 source /etc/profile即可更新环境变量

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐