乐趣区

关于jupyter-notebook:JupyterLab-交互式笔记本的安装使用

介绍

JupyterLab 是基于 Web 的交互式开发环境,是 Jupyter 下一代的 Notebook 界面。

能够解决 Jupyter notebooks (.ipynb),编辑文本 (.md, .csv, .json, …),查看文件 (images, PDF, …),操作终端等。

另外,

  • 交互式,指文本与代码的交互。意味着文本中的代码,如 Markdown 代码段,可间接运行。
  • 开发环境,表明其性能足够弱小,更像是一个 IDE。扩大插件也让咱们能自定义或加强各种性能。

官网文档:https://jupyterlab.readthedoc…

装置

举荐以下两种形式之一:

  • Anaconda: Anaconda 是用于科学计算的 Python 发行版,自带有 JupyterLab。
  • Docker: Docker 是一个开源的容器引擎,能够间接拉取 JupyterLab 镜像环境。

Anaconda

下载地址:https://www.anaconda.com/prod…

conda 查看:

❯ conda list | grep jupy
jupyter                   1.0.0                    py37_7
jupyter_client            5.3.4                    py37_0
jupyter_console           6.1.0                      py_0
jupyter_core              4.6.1                    py37_0
jupyterlab                1.2.6              pyhf63ae98_0
jupyterlab_server         1.0.6                      py_0

装置:

conda install -c conda-forge jupyterlab

或更新:

conda update -c conda-forge jupyterlab

开始应用

jupyter lab

浏览器会关上:

Docker

下载地址:https://docs.docker.com/engin…

拉取镜像:

docker pull jupyter/scipy-notebook:latest

常驻运行:

docker run -d --restart=always \
--name jupyter \
-p 8888:8888 \
-e JUPYTER_ENABLE_LAB=yes \
-v "$HOME":/home/jovyan/work \
jupyter/scipy-notebook:latest
  • --restart=always 是为了重启后仍放弃运行
  • $HOME 是用于映射进容器的本地工作门路

浏览器拜访 http://localhost:8888/lab

提醒输出 Token,能够查看 jupyter 日志获取:

❯ docker logs jupyter
Executing the command: jupyter lab
[I 22:32:45.229 LabApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[I 22:32:46.051 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.8/site-packages/jupyterlab
[I 22:32:46.051 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 22:32:46.054 LabApp] Serving notebooks from local directory: /home/jovyan
[I 22:32:46.054 LabApp] Jupyter Notebook 6.1.4 is running at:
[I 22:32:46.054 LabApp] http://e1839b94c616:8888/?token=fc8d547d3d9cb47ae8d855fbb3f788e0c045e0061012a917
[I 22:32:46.054 LabApp]  or http://127.0.0.1:8888/?token=fc8d547d3d9cb47ae8d855fbb3f788e0c045e0061012a917
[I 22:32:46.054 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 22:32:46.059 LabApp]

    To access the notebook, open this file in a browser:
        file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html
    Or copy and paste one of these URLs:
        http://e1839b94c616:8888/?token=fc8d547d3d9cb47ae8d855fbb3f788e0c045e0061012a917
     or http://127.0.0.1:8888/?token=fc8d547d3d9cb47ae8d855fbb3f788e0c045e0061012a917

最终,输出 token fc8d547d3d9cb47ae8d855fbb3f788e0c045e0061012a917 登录。

Chrome 浏览器能够利用 Chrome Apps 创立桌面快捷。

更多镜像

  • Selecting an Image: https://jupyter-docker-stacks…

插件

启用

JupyterLab 侧边栏有插件选项,关上后会提醒“Enable”,确认即可。

装置

“SEARCH”里搜寻想要的插件。例如图表绘制插件 DrawIO:

装置后 Launcher Other 里会多出 Diagram,关上编辑:

更多插件

  • Awesome JupyterLab

结语

欢送关注 GoCoding 公众号,分享日常 Coding 中实用的小技巧、小常识!

退出移动版