文章目錄
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
設置遠程訪問
jupyter notebook --generate-config
- 生成密碼的哈希值
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:8XXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXf'
- 修改~/.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
給不同用戶開啓不同的jupyter服務
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 代碼補全
優化體驗操作
寫代碼的初始設置
- 全部設置彙總見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