refer
参考这个进行远程端口转发 建立ssh隧道
jupyter notebook --no-browser --port=xxxx
ssh -N -f -L localhost:8888:localhost:xxxx -p 22 remote_user@remote_host
访问http://localhost:8888/
- 注意啊 ,这里端口转发以后是访问localhost:8888不是访问server_ip:8888 ( 看错躺坑了好久…
参考这个进行密码设置hash设置
- 注意,配置文件在~/.jupyter里面的jupyter_notebook_config.py里面 ( 前提是你已经执行过生成配置文件的命令 )
基本配置
设置远程访问
jupyter notebook --generate-config
- 生成密码的哈希值
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:8XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXf'
- 修改~/.jupyter/jupyter_notebook_config.py文件
c.NotebookApp.ip = '*'
c.NotebookApp.password = 'sha1:8XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxf'
c.NotebookApp.open_browser = False
c.NotebookApp.port = xxxx
c.NotebookApp.allow_remote_access = True
有人把allow-root也设置成了True,我这是公网的ip,安全起见就不了
- 启动
jupyter notebook
nbextension安装
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
pip install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
- 常用插件
代码折叠 Codefolding
标题折叠 Collapsible Headings
自动整理代码 首先安装yapf,然后把Code prettify打开即可
启用后可以按快捷键,或者点锤子图标进行代码自动整理
Notify
Toggle line numbers
table of contents
Hinterland 代码补全
优化体验操作
- 配置密码( 空格多爽 (hash没有配置还
写代码的初始设置
- 全部设置汇总见gist
InteractiveShell
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity='all'
- 改回来的命令
InteractiveShell.ast_node_interactivity='last_expr'
matplotlib
%matplotlib inline
运行前自动装载模块
%load_ext autoreload
%autoreload 2