Jupyter如何优雅禁止termin

修改前端 JavaScript

1、在 Jupyter 配置目录下创建一个自定义的 custom.js 文件:

复制代码
mkdir -p ~/.jupyter/custom 

touch ~/.jupyter/custom/custom.js

2、在 custom.js 文件中添加以下 JavaScript 代码来覆盖感叹号命令的行为:

复制代码
require(['base/js/namespace'], function(Jupyter) {
    var old_execute = Jupyter.notebook.kernel.execute;
    Jupyter.notebook.kernel.execute = function(code, callbacks, options) {
        if (code.trim().startsWith('!')) {
            console.warn('Usage of "!" for system commands is disabled.');
            return;
        }
        old_execute.call(this, code, callbacks, options);
    };
});
3、修改 Jupyter Notebook 配置文件 ~/.jupyter/nbconfig/notebook.json,包含对 custom.js的引用:
复制代码
{
  "load_extensions": {
    "custom/custom.js": true
  }
}
4、重启 Jupyter Notebook,使配置生效。
相关推荐
2401_871696525 小时前
macOS 中使用 launchd 每分钟执行一次 PHP 脚本的完整配置指南
jvm·数据库·python
吕源林5 小时前
MongoDB副本集在网络闪断后如何快速恢复_重连机制与心跳超时(electionTimeoutMillis)
jvm·数据库·python
emovie5 小时前
Python函数基础
linux·数据库·python
Polar__Star5 小时前
SQL中JOIN不同存储引擎表的影响_索引兼容性与查询性能评估
jvm·数据库·python
2301_815279525 小时前
golang如何实现数据导入进度跟踪_golang数据导入进度跟踪实现教程
jvm·数据库·python
hsg775 小时前
简述:pytorch
人工智能·pytorch·python
YuanDaima20485 小时前
矩阵基础原理与题目说明
人工智能·笔记·python·学习·线性代数·矩阵
环小保5 小时前
NMP回收设备厂家深度解析:锂电绿色制造的核心力量
python·制造
InfinteJustice5 小时前
golang如何使用struct嵌套_golang struct结构体嵌套使用方法.txt
jvm·数据库·python
Dxy12393102166 小时前
Python如何去掉文本中的表情符号
开发语言·python