JupyterLab代码片段扩展
项目描述
jupyterlab-snippets
JupyterLab 的代码片段扩展。
此扩展由名为 jupyterlab-snippets
的 Python 包组成,用于服务器扩展,以及名为 jupyterlab-snippets
的 NPM 包,用于前端扩展。
需求
- JupyterLab >= 2.0
- Node.js
安装
使用 conda
conda install -c conda-forge jupyterlab-snippets
使用 pip
pip install jupyterlab-snippets
如果您使用的是 JupyterLab 2.x,您将需要使用以下内容重新构建 JupyterLab:
jupyter lab build
使用方法
在 [jupyter_data_dir]/snippets
中添加代码片段(见:https://jupyter-docs.pythonlang.cn/en/latest/projects/jupyter-directories.html#id2)
要查找 Jupyter 数据目录,请运行
$ jupyter --path
例如,在 macOS 上将显示以下列表
config:
/Users/<username>/.jupyter
...
data:
/Users/<username>/Library/Jupyter
/Users/<username>/miniconda3/envs/<envname>/share/jupyter
...
runtime:
...
使用列在 data:
下的第一个目录来添加文件,这些文件将成为菜单中的代码片段。每个文件包含一个代码片段。目录可用于组织代码片段文件,并将成为菜单中的子菜单。
在 JupyterLab 中,使用 "代码片段" 菜单选择代码片段
将代码片段从 jupyter-boilerplate 格式转换
有关如何将代码片段从 jupyter-boilerplate 经典笔记本扩展(不适用于 JupyterLab)转换为 jupyterlab-snippets 的说明,请参阅 jupyter-boilerplate-converter。
故障排除
如果您看到前端扩展但无法使用,请检查服务器扩展是否已启用
jupyter serverextension list
如果服务器扩展已安装并启用,但您看不到前端,请检查前端扩展是否已安装并启用
jupyter labextension list
如果已安装,请尝试
jupyter lab clean
jupyter lab build
开发安装
注意:您将需要 NodeJS 来构建扩展包。
jlpm
命令是 JupyterLab 随附的 yarn 的固定版本。您可以使用 yarn
或 npm
代替以下内容中的 jlpm
。
# Clone the repo to your local environment
# Change directory to the jupyterlab-snippets directory
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm run build
您可以在不同的终端中同时监视源目录并运行 JupyterLab,以监视扩展源代码的变化并自动重新构建扩展。
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
# Run JupyterLab in another terminal
jupyter lab
在监视命令运行时,每次保存的更改都将立即在本地上构建并可供运行的 JupyterLab 使用。刷新 JupyterLab 以在浏览器中加载更改(您可能需要等待几秒钟以重建扩展)。
默认情况下,jlpm run build
命令为该扩展生成源映射,以便更容易使用浏览器开发工具进行调试。要为 JupyterLab 核心扩展也生成源映射,可以运行以下命令
jupyter lab build --minimize=False
卸载
pip uninstall jupyterlab-snippets
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。
源分发
构建分发
jupyterlab-snippets-0.4.1.tar.gz 的散列
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8f054bb257b31f20732702962d251924693973a410fcd887d68ec72418d0711c |
|
MD5 | 3f3e56aae52a8384ecebcd0d3606a51d |
|
BLAKE2b-256 | 67dc400d6d7e60aee792fad9f18519b078c0e28c21a1813568ff30282bb6136a |
jupyterlab_snippets-0.4.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 83782841dcce5af5b346d1deb84711595f27b8dd1fd57831221a87baf481084f |
|
MD5 | 3e85a9347d867da33e6f8770328d6087 |
|
BLAKE2b-256 | 9a57df8fef3289a43a68c1a0bcc2d0a2911a4726d15ecc85a10d58cd273c034e |