栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Jupyter notebook在mac:linux上的配置和远程访问的方法

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Jupyter notebook在mac:linux上的配置和远程访问的方法

upyter Notebook已经逐渐取代IDE成为了多平台上写简单Python脚本或应用的几家选择。

Jupyter Notebook可以通过pip/pip3安装:

pip3 install jupyter

然后在目标文件夹目录下,输入指令jupyter notebook开启服务,可在浏览器地址localhost:8888中访问主页

允许远程访问

在本地,我们访问localhost:8888就能看到Jupyter Notebook的本地主页,但是在远程访问中,并不能直接这么做。因此需要以下一些操作:

1. 生成一个 notebook 配置文件

默认情况下,配置文件 ~/.jupyter/jupyter_notebook_config.py 并不存在,需要自行创建。使用下列命令生成配置文件:

jupyter notebook --generate-config

如果是 root 用户执行上面的命令,会发生一个问题:

Running as root it not recommended.
Use --allow-root to bypass.

提示信息很明显,root 用户执行时需要加上 –allow-root 选项。

jupyter notebook --generate-config --allow-config

执行成功后,会出现下面的信息:

Writing default config to: /root/.jupyter/jupyter_notebook_config.py

2. 生成密码

从 jupyter notebook 5.0 版本开始,提供了一个命令来设置密码:jupyter notebook password,生成的密码存储在 jupyter_notebook_config.json。

$ jupyter notebook password
Enter password: ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_confi

3. 远程访问

以上设置完以后就可以在服务器上启动 jupyter notebook,jupyter notebook, root 用户使用 jupyter notebook --allow-root。打开 IP:指定的端口(默认为8888), 输入密码就可以访问了。

若8888端口被占用,浏览器打开 IP:指定的端口(默认为8888) 应该访问不了,可以用如下方式启动 jupyter notebook

jupyter notebook --no-browser --port 6000 --ip=192.168.1.103

就是指定端口号和ip。通过这种方式在浏览器输入 ip:端口号,应该就能看到对应界面了。

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对考高分网的支持。如果你想了解更多相关内容请查看下面相关链接

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/27498.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号