6.Python - Jupyter

作者: 风云雄霸天下123456 | 来源:发表于2017-09-05 13:40 被阅读75次

参考:


1. 搭建:


2. 自定义添加快捷键

  • 参考:

    1. keyboard shortcut to clear cell output in jupyter notebook
  • 操作:

    1. 修改custom.js文件
      # 文件位置,如果文件不存在,则创建
      ~/.jupyter/custom/custom.js
      
    2. 添加代码
      require(['base/js/namespace'], function(){
          "use strict";
      
          // setup shortcuts
          // ctrl-l: clear current cell output
          Jupyter.keyboard_manager.command_shortcuts
                 .add_shortcut('ctrl-l', 'jupyter-notebook:clear-cell-output');
          // ctrl-shift-l: clear all cells output
          Jupyter.keyboard_manager.command_shortcuts
                 .add_shortcut('ctrl-shift-l', 'jupyter-notebook:clear-all-cells-output');
          // f2: rename file
          Jupyter.keyboard_manager.command_shortcuts
                 .add_shortcut('f2', 'jupyter-notebook:rename-notebook');
          // ctrl-r: run all cells
          Jupyter.keyboard_manager.command_shortcuts
                 .add_shortcut('ctrl-r', 'jupyter-notebook:run-all-cells');
      });
      
    3. 重启Jupyter即可

3. 引入自定义模块

  • 参考:

  • 操作:

    %run 'Title.ipynb'
    %run 'a.py'
    

4. 支持使用多变量输出

  • 说明:
    在Jupyter里直接写变量是输出,但只支持单变量输出。使用此方法,支持多变量输出
  • 操作:
    1. 修改:~/.ipython/profile_default/ipython_config.py文件
      c = get_config()
      # Run all nodes interactively
      c.InteractiveShell.ast_node_interactivity = "all"
      
    2. 重启服务即可

5. 添加密码:

  • 参考:
    1. jupyter - 密码配置
  • 说明:
    1. 执行命令
      # 执行命令
      jupyter notebook password
      
    2. 结果写入文件:~/.jupyter/jupyter_notebook_config.json
        {
          "NotebookApp": {
            "password": "sha1:91f648919f92:81b6fd6974d0718f2912db41203c26b3fa5c5591",
            "server_extensions": [
              "jupyter_nbextensions_configurator"
            ]
          }
        }
      

相关文章

网友评论

    本文标题:6.Python - Jupyter

    本文链接:https://www.haomeiwen.com/subject/ayevrxtx.html