机器学习环境配置系列六之jupyter notebook远程访问

jupyter运行后只能在本机运行,如果部署在服务器上,大家都希望可以远程录入地址进行访问,这篇文章就是解决这个远程访问的问题。几个基本的命令就可以搞定,然后就可以愉快的玩耍了。

1、安装jupytetr

conda install jupyter

2、远程访问配置

jupyter notebook --generate-config
jupass = 'python -c"from notebook.auth
import passwd; print(passwd())"'

echo "c.NotebookApp.password = u'"$jupass"'" >> .jupyter/jupyter_notebook_config.py

echo "c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = Flase
c.NotebookApp.port = 端口号">> .jupyter/jupyter_notebook_config.py

  注:如果服务器是固定ip地址,c.NotebookApp.ip 也可以指定固定的ip更稳定

3、开启linux端口命令

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT #开启80端口 
/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT #开启22端口 
/etc/rc.d/init.d/iptables save #保存配置 
/etc/rc.d/init.d/iptables restart #重启服务 
查看已开放端口 
/etc/init.d/iptables status 

4、启动jupyter

jupyter notebook

  启动信息如下:

[I 18:52:57.324 NotebookApp] Serving notebooks from local directory: /home/用户名
[I 18:52:57.324 NotebookApp] The Jupyter Notebook is running at:
[I 18:52:57.324 NotebookApp] http://ip:port/
[I 18:52:57.324 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 19:17:27.484 NotebookApp] Kernel started: 78d6fb00-dadd-4cfa-91d8-7102d7907599
[I 19:17:31.084 NotebookApp] Adapting to protocol v5.1 for kernel 78d6fb00-dadd-4cfa-91d8-7102d7907599
[W 19:17:47.801 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20181024185257 10.92ms re

5、字符集问题

如果linux用的是中文字符集jupyter启动很容易出现问题,如果出现类似问题,把linux改为英文,包治百病。

上述只是jupyter的简单配置,复杂的参数配置请大家自行研究,这个内容可以满足基本的使用需求了。

转载于:https://www.cnblogs.com/jaww/p/9846491.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值