服务器jupyter notebook基本设置

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
c.NotebookApp.notebook_dir = '/home/xx'  # 设置成你想要的启动目录

有人把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 代码补全

这些插件实际上就在/home/YourName/.jupyter/nbconfig里面,以后要迁移,可以直接复制这个文件。

优化体验操作

写代码的初始设置

  • 全部设置汇总见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

用法以及在jupyter上的配置这个博文
参数含义见这个博客

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值