jupyter 远程访问,主题,字体设置,快捷键

安装jupyter

我的系统默认python 版本为python2, 在python2 环境下安装jupyter, pytyon解释器只有python2.我在python3环境也安装jupyter后,就能看到python2,python3解释器了。

pip install jupyter

pip3 install jupyter

完成上面步骤后,对jupyter 进行配置。创建配置文件 ~/.jupyter/jupyter_notebook_config.py

jupyter notebook --generate-config

生成访问密码,在通过浏览器访问时需要填写,认证。

ubuntu@VM-0-3-ubuntu:~/workspace$ ipython

Python 3.6.8 (default, Oct  7 2019, 12:59:55)

Type 'copyright', 'credits' or 'license' for more information

IPython 7.11.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd

In [2]: passwd()

Enter password:

Verify password:

Out[2]: 'sha1:2bd31af20543:daf1695b7fbc8e34444dd1b4ba04f1748bc23f4f'

修改jupyter 相关访问配置

vim ~/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip='192.168.1.158' #如果是云端服务器,需要填写云服务商的内网ip

c.NotebookApp.password = u'' #前面手动生成的 sha1:2bd31af20543:daf1695b7fbc8e34444dd1b4ba04f1748bc23f4f

c.NotebookApp.open_browser = False #

c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口228行

配置完成后,启动服务端

jupyter notebook # 我的是云端服务器,通过外网IP 访问

nohup jupyter notebook --allow-root & #在后台运行


黑色护眼主题,字体设置

pip3 install jupyterthemes

jt -l #查看可用主题

我的配置如下:

jt -t onedork -f source -fs 18 -tf robotosans -tfs 16 -nf robotosans -nfs 16 -ofs 14 -T


jt : jupyterthemes 命令

-t: 采用的主题

-f:代码的字体

-fs: 代码的字号

-tf:文本(markdwon)字体

-tfs: 文本(markdwon)字体大小

-nf:notebook的界面字体

-nfs:notebook的界面字体大小

-T(显示工具栏) 

-N(显示自己主机名)

这是我想要的效果。


快捷键


执行当前cell,并自动跳到下一个cell:Shift Enter

执行当前cell,执行后不自动调转到下一个cell:Ctrl-Enter

是当前的cell进入编辑模式:Enter

退出当前cell的编辑模式:Esc

删除当前的cell:双d

在命令模式,在上方插入cell:a

在命令模式,在下方插入cell:b

保存文件: ctrl + s

当前cell转入markdown状态:m

当前cell转入代码状态:y

当前cell装入raw文本状态:r

为当前的cell加入line number:单L

将当前的cell转化为具有一级标题的maskdown:单1

将当前的cell转化为具有二级标题的maskdown:单2

将当前的cell转化为具有三级标题的maskdown:单3

为一行或者多行添加/取消注释:Crtl /

撤销对某个cell的删除:z

浏览器的各个Tab之间切换:Crtl PgUp和Crtl PgDn

快速跳转到首个cell:Crtl Home

快速跳转到最后一个cell:Crtl End


问题处理

在安装主题后,出现部分内容遮挡的情况

在目录下notebook 配置文件 /home/ubuntu/.jupyter/nbconfig,可以通过(jupyter --config-dir) 找到

我的配置如下 notebook.json

注意加入

MarkdownCell

CodeCell

{

"Notebook": {

    "Header": true,

    "Toolbar": true

  },

"Cell": {

    "cm_config": {

      "lineNumbers": true

    }

  },

"MarkdownCell": {

    "cm_config": {

      "lineWrapping": true

    }

  },

    "CodeCell": {

    "cm_config": {

      "lineWrapping": true

    }

  }

}



参考文章:

jupyter自定义字体和大小、主题安装实例及效果图

Jupyter的各种快捷键

你可能感兴趣的:(jupyter 远程访问,主题,字体设置,快捷键)