Linux下配置jupyter notebok并进行远程访问(详细)+ 一键配置脚本

1、安装jupyter
 pip install jupyter
2、生成配置文件
jupyter notebook --generate-config
3、配置文件的路径为:
~/.jupyter/jupyter_notebook_config.py
4、进入python环境,依次执行:
 python
 from notebook.auth import passwd
 passwd()

执行上述命令后会让你设置一个密码,这个密码是你在远程windows上访问时需要的密码。输入两次密码后会生成一个密钥:
‘sha1:d66351142f0a:9eea3d7f99e434a6837f5e73af18d03cf0353392’

5、退出python环境
exit()
6、修改配置文件
vim ~/.jupyter/jupyter_notebook_config.py

修改1、
c.NotebookApp.password = u’sha1: d66351142f0a:9eea3d7f99e434a6837f5e73af18d03cf0353392’
修改2、
c.NotebookApp.ip = ‘*’
修改3、
c.NotebookApp.open_browser = False
修改4、
c.NotebookApp.port = 12345(自己任意设置)
修改5、
c.NotebookApp.allow_remote_access = True

7、启动jupyter
jupyter notebook
8、访问
linux服务器的ip:12345
如192.168.3.210:12345

PS:12345是刚在配置文件设置的端口

参考:https://jingyan.baidu.com/article/c33e3f48de2308ea15cbb5d4.html

一键配置脚本

将下面脚本内容保存为jupyter_config_and_install.sh,然后再需要配置的服务器运行bash jupyter_config_and_install.sh,中间会提示让你设置密码,可以按回车跳过。

#!/bin/bash

# Step 1: Install Jupyter
pip install jupyter

# Step 2: Generate configuration file
jupyter notebook --generate-config

# Step 3: Configuration file path
config_file=~/.jupyter/jupyter_notebook_config.py

# Step 4: Generate password hash
password_hash=$(python - <<END
from notebook.auth import passwd
print(passwd())
END
)

# Step 5: Modify configuration file
cat <<EOT >> $config_file
c.NotebookApp.password = u'$password_hash'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 12345
c.NotebookApp.allow_remote_access = True
EOT

# Step 6: Start Jupyter Notebook
jupyter notebook
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值