Linux 服务器配置Jupyter notebook, 并支持在win的浏览器上面打开

Linux 服务器配置Jupyter notebook, 并支持在win的浏览器上面打开

安装步骤:

1. 安装jupyter:

pip install jupyter

2. 生成notebook配置文件:

jupyter notebook --generate-config

执行后会在/home/usename 目录下生成 .jupyter目录,里面包含几个文件:

3. 配置jupyter notebook密码:

$ jupyter notebook password

执行后会输入两次密码,设置了jupyter notebook的密码

4. 设置允许win远程访问(学会使用vim编辑文件,点击vim使用参考博客):

vim ~/.jupyter/jupyter_notebook_config.py

# 然后在里面修改的内容有:
# 1. 第82行,False 改为 True, 允许远程访问
c.NotebookApp.allow_remote_access = True  
# 2. 第204行,'localhost'改为'*',允许任意ip地址访问
c.NotebookApp.ip = '*'
# 3. 第272行,True 改为 False, 关闭启动后自动打开浏览器
c.NotebookApp.open_browser = False

5. 启动jupyter

jupyter notebook

# 然后就可以看到
[W 16:30:17.129 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 16:30:17.129 NotebookApp] The port 8888 is already in use, trying another port.
[I 16:30:17.133 NotebookApp] Serving notebooks from local directory: /home/chenbaoying/.jupyter
[I 16:30:17.133 NotebookApp] The Jupyter Notebook is running at:
[I 16:30:17.133 NotebookApp] http://gtx1080gpu2:8889/
[I 16:30:17.133 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

6. win 浏览器打开, 把http://gtx1080gpu2:8889/ 替换为 http://ip:8889/ , 比如我的服务器的ip是 172.31.2.2, 那我再浏览器中输入的url是; http://172.31.2.2:8889/ ,每次重新启动jupyter需要输入前面设置的密码。

7. 有时候启动后,在win上仍然访问不了,主要原因是指定的端口在Liunx上面没有开放,这时候需要手动开放指定的端口

sudo /sbin/iptables -I INPUT -p tcp --dport 8889 -j ACCEPT

参考博客:

1. 在Linux服务器上运行Jupyter notebook server教程

2. 服务器上Jupyter notebook环境搭建

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值