PyCharm专业版连接jupyter notebook,添加nbextensions插件


一、在工程中新建jupyter notebook

(1)打开pycharm软件,右击项目工程->new->jupyter notebook;
(2)在弹出的小窗口中填写名称(例如jupyter_notebook)
(3)右侧工程项目文件中则出现一个jupyter_notebook.ipynb文件

二、让jupyter notebook跳转到浏览器

(1)测试在cell里面输入print('hello'),点击旁边的运行按钮,右侧出现运行结果,但是这样是非常不方便的
(2)点击最下面的【Terminal】,输入jupyter notebook,回车后就会跳转到浏览器
(3)如果没有跳转,点击蓝色连接

三、安装nbextensions插件

如果没有安装插件管理器,打开jupyter notebook后菜单栏只有如下3项

(1)点击【File】->【Settings】->【Project】->【Python Interpreter】->【+】

(2)搜索框里输入“nbextensions”,将结果中的两个库都安装

(3)配置:在Terminal里输入下面两行代码

jupyter nbextensions_configurator enable --user 
jupyter contrib nbextension install --user --skip-running-check 
 

(4)重启软件后,浏览器jupyter notebook出现新的 Nbextensions 选项卡;取消“√”;按需选择插件

(5)常用插件

    Hinterland :自动补全代码
    Snippets Menu : 在菜单栏中增加可自定义的菜单栏,用以插入代码片段
    spellchecker : 拼写检查,高亮显示拼写错误的单词
    Split Cells Notebook : 增加拆分单元格的命令
    Table of Contents(2) : 增加浮动目录功能
    table_beautifier : 美化输出的单元格
    Toggle all line numbers : 在工具栏中增加一个控制所有单元格行号是否显示的工具
    Tree Filter : 在Jupyter笔记本文件树页面中增加按文件名过滤的功能
    Variable Inspector : 在工具栏中增加变量检查的功能
    zenmode : 增加Zenmode功能扩展

(6)测试:新建python文件,在markdown下写标题,运行后,点击右上角的"三"形状,左侧就会出现目录