Jupyter notebook在mac:linux上的配置和远程访问的方法
upyterNotebook已经逐渐取代IDE成为了多平台上写简单Python脚本或应用的几家选择。
JupyterNotebook可以通过pip/pip3安装:
pip3installjupyter
然后在目标文件夹目录下,输入指令jupyternotebook开启服务,可在浏览器地址localhost:8888中访问主页
允许远程访问
在本地,我们访问localhost:8888就能看到JupyterNotebook的本地主页,但是在远程访问中,并不能直接这么做。因此需要以下一些操作:
1.生成一个notebook配置文件
默认情况下,配置文件 ~/.jupyter/jupyter_notebook_config.py 并不存在,需要自行创建。使用下列命令生成配置文件:
jupyternotebook--generate-config
如果是root用户执行上面的命令,会发生一个问题:
Runningasrootitnotrecommended.
Use--allow-roottobypass.
提示信息很明显,root用户执行时需要加上–allow-root选项。
jupyternotebook--generate-config--allow-config
执行成功后,会出现下面的信息:
Writingdefaultconfigto:/root/.jupyter/jupyter_notebook_config.py
2.生成密码
从jupyternotebook5.0版本开始,提供了一个命令来设置密码:jupyternotebookpassword,生成的密码存储在 jupyter_notebook_config.json。
$jupyternotebookpassword Enterpassword:**** Verifypassword:**** [NotebookPasswordApp]Wrotehashedpasswordto/Users/you/.jupyter/jupyter_notebook_confi
3.远程访问
以上设置完以后就可以在服务器上启动 jupyternotebook,jupyternotebook,root用户使用 jupyternotebook--allow-root。打开IP:指定的端口(默认为8888),输入密码就可以访问了。
若8888端口被占用,浏览器打开 IP:指定的端口(默认为8888)应该访问不了,可以用如下方式启动 jupyternotebook
jupyternotebook--no-browser--port6000--ip=192.168.1.103
就是指定端口号和ip。通过这种方式在浏览器输入ip:端口号,应该就能看到对应界面了。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对毛票票的支持。如果你想了解更多相关内容请查看下面相关链接