【jupyter notebook】本地浏览器访问远程 jupyter notebook

  1. 生成配置文件:jupyter notebook --generate-config

  2. 设置Jupyter远程访问密码:jupyter notebook password

  3. 手动生成一个hash密码,输入ipython,再依次输入如下语句:

    注:这两个密码都是输入同一个,不同的密码没试过

    from notebook.auth import passwd
    passwd() # 这里会输出hash密码,保存下来有用
    exit()
    
  4. 将hash密码添加到配置文件中,输入vi ~/.jupyter/jupyter_notebook_config.py,打开第一步生成的配置文件,写入如下内容:

    # c = get_config()
    # c.IPKernelApp.pylab = "inline"
    c.NotebookApp.ip = "*"
    c.NotebookAPp.open_browser = False
    c.NotebookApp.password = u'sha1:510eb39a87fb:62750c222931916f55d75b53a7847aa062ca5a57'
    # c.NotebookApp.certfile = u'/home/hhh/.jupyter/mycert.pem'
    c.NotebookApp.port=1924
    c.NotebookApp.notebook_dir = "/home/hhh/ipythonFiles/"
    c.NotebookApp.allow_remote_access = True
    
  5. 创建文件夹:mkdir ipythonFiles

  6. 使修改的配置生效,输入:jupyter notebook

  7. 放行Linux防火墙的端口

    端口号要和配置文件的端口号一致

    sudo firewall-cmd --zone=public --add-port=1924/tcp --permanent
    sudo systemctl restart firewalld # 使防火墙生效
    
  8. 启动Jupyter服务器,并让这个服务器后台运行:nohup jupyter notebook &

    nohup jupyter lab &

  9. 到本地浏览器输入:remote_server_ip:port

    remote_server_ip:远程服务器IP地址

    port:远程服务器端口号

感谢参考资料:如何设置远程访问的Jupyter Notebook服务器-04(服务器篇)

‘sha1:510eb39a87fb:62750c222931916f55d75b53a7847aa062ca5a57’


跑的另一个jupyter服务:(修改端口号,最好也修改路径)

# c = get_config()
c.IPKernelApp.pylab = "inline"
c.NotebookApp.ip = "*"
c.NotebookAPp.open_browser = False
c.NotebookApp.password = u'sha1:c510322c37eb:41a0997fe87cf205e4592eeeed5c0c213a4b2ae8'
# c.NotebookApp.certfile = u'/home/hhh/.jupyter/mycert.pem'
c.NotebookApp.port=1919
c.NotebookApp.notebook_dir = "/home/hhh/ipythonFiles_mylearning/"
c.NotebookApp.allow_remote_access = True

修改完后,需要激活配置文件:jupyter lab --config ~/.jupyter/jupyter_notebook_config_mylearning.py

使用不同的配置文件即可运行多个jupyter服务

放行 1919 端口

使用不同的配置文件,挂到服务器后台运行:
nohup jupyter notebook --config ~/.jupyter/jupyter_notebook_config_mylearning.py &

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值