跳转到主要内容

JupyterLab中笔记本的任意Python命令

项目描述

jupyterlab_commands

在命令调色板中支持任意Python命令。

Build Status codecov PyPI PyPI npm Binder

关于

此代码允许您将任意命令注入到JLab前端。可能有各种原因需要在笔记本和终端之外执行Python命令

  • 您不希望包含在转换结果中的预定义NBConvert函数
  • 与VCS交互,而不将此交互包含在笔记本中
  • 等等...

安装

pip install jupyterlab_commands
jupyter labextension install jupyterlab_commands
jupyter serverextension enable --py jupyterlab_commands

示例

jupyter_lab_config.py

def convertMe(request, *args, **kwargs):
    import subprocess, tornado, os, os.path, json
    data = json.loads(tornado.escape.json_decode(request.body))
    path = os.path.join(os.getcwd(), data['path'])
    subprocess.run(["jupyter", "nbconvert", path, '--to', 'html'])
    return {'body': 'ok'}

c.JupyterLabCommands.commands = {'sample_command': convertMe}

命令调色板

终端日志

无代码

已移动到 jupyterlab_nbconvert_nocode

安装

pip install jupyterlab_commands
jupyter labextension install jupyterlab_commands
jupyter serverextension enable --py jupyterlab_commands

添加命令

安装服务器扩展,并将以下内容添加到 jupyter_notebook_config.py

c.JupyterLabCommands.commands = {'command display name': python_function, ...}

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关 安装软件包 的更多信息。

源代码分发

jupyterlab_commands-0.4.0.tar.gz (160.9 kB 查看哈希值)

上传时间 源代码

构建分发

jupyterlab_commands-0.4.0-py3-none-any.whl (44.0 kB 查看哈希值)

上传时间 Python 3