欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Jupyter notebook远程访问服务器

程序员文章站 2022-05-27 19:21:13
...

1. 登陆服务器

2. 安装jupyter notebook

pip install jupyter notebook

3. 生成配置文件

jupyter notebook --generate-config

4. 生成密码(后续写配置文件、登录Jupyter notebook需要)

打开`ipython`终端

In [1]: from IPython.lib import passwd

In [2]: passwd()
Enter password: # 在这里要自己设一个密码,远程登陆服务器的时候会需要
Verify password: 
Out[2]: 'sha1:0e422dfccef2:84cfbcbb3ef95872fb8e23be3999c123f862d856' # 要记住

5. 修改默认配置文件

vim ~/.jupyter/jupyter_notebook_config.py 
import os
from IPython.lib import passwd

c.NotebookApp.ip = '*'
# 这一个字符串要换成自己刚刚生成的密码
c.NotebookApp.password = u'sha1:6fa09117fcc3:219f6e6e778d124cdd35c8f9ad087faef575f62d'
c.NotebookApp.port = int(os.getenv('PORT', 8888))
c.NotebookApp.open_browser = False
c.NotebookApp.allow_remote_access = True

6. 启动jupyter

jupyter notebook --allow-root

7. 远程方法

此时应该可以直接从本地浏览器直接访问http://address_of_remote:8888就可以看到jupyter的登陆界面。(特别注意:服务器上的Jupyter notebook不要关)

参考:https://blog.csdn.net/a819825294/article/details/55657496