2020年8月27日 / 605次阅读 / Last Modified 2020年8月27日
一直久闻Jupyter的大名,今天终于有心情实践一下。查阅了一番官网信息,貌似现在已经叫做JupyterLab了。
安装JupyterLab:
sudo pip3 install jupyterlab
我喜欢用sudo,我的环境我独享!安装过程有点漫长,有一大堆依赖库...
启动jupyterlab:
$ /usr/local/python-3.8/bin/jupyter lab
这样启动说明jupyter这个程序默认不再$PATH环境变量中,这个问题请自行处理。
启动之后,jupyter有一堆打印,默认端口是8888,但是这时通过网络不能访问!折腾了一番发现是默认监听地址的问题,默认情况下,只能在localhost里用浏览器访问,这个需要修改。
[I 17:30:08.822 LabApp] JupyterLab extension loaded from /usr/local/python-3.8.3/lib/python3.8/site-packages/jupyterlab [I 17:30:08.822 LabApp] JupyterLab application directory is /usr/local/python-3.8.3/share/jupyter/lab [I 17:30:08.829 LabApp] Serving notebooks from local directory: /home/pi [I 17:30:08.829 LabApp] Jupyter Notebook 6.1.3 is running at: [I 17:30:08.829 LabApp] http://rpi01:8888/?token=be933e72629b76b8130ee7f4bc2c2cc6c46098b35ce3e2d7 [I 17:30:08.829 LabApp] or http://127.0.0.1:8888/?token=be933e72629b76b8130ee7f4bc2c2cc6c46098b35ce3e2d7 [I 17:30:08.829 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [W 17:30:08.851 LabApp] No web browser found: could not locate runnable browser. [C 17:30:08.852 LabApp] To access the notebook, open this file in a browser: file:///home/pi/.local/share/jupyter/runtime/nbserver-2154-open.html Or copy and paste one of these URLs: http://rpi01:8888/?token=be933e72629b76b8130ee7f4bc2c2cc6c46098b35ce3e2d7 or http://127.0.0.1:8888/?token=be933e72629b76b8130ee7f4bc2c2cc6c46098b35ce3e2d7
生产配置文件,并配置:
$ /path/to/jupyter lab --generate-config
然后找到终端显示出来的配置文件,打开编辑,修改这一行为:
## The IP address the notebook server will listen on.
c.NotebookApp.ip = '0.0.0.0'
大概200多行的位置,然后保存退出,重新启动jupyterlab,你就可以通过网络在浏览器中访问了。
启动jupyterlab时,界面上有一个token,网页登录时需要用到这个token。当然,我个人的私有环境这样搞没问题,如果是在公网上,建议你还是设置一个密码来访问。
JupyterLab的确不同凡响,通过网页集成了很多方便的功能,可以用它来写书了!:)
一个小技巧,用下面这条命令启动jupyterlab,然后可以关闭终端,用jupyterlab内的终端连接服务器(不用输密码)。
$ nohup /path/to/jupyter lab &
nohup是让此进程的运行不与当前用户挂钩,&表示后台运行。
其实,我想用jupyterlab的初衷,只是想在python shell敲的有些代码,能够更方便的查找和copy出来。没想到jupyterlab的确给了我一个惊喜,简化了一些日常事务。
-- EOF --
本文链接:https://www.pynote.net/archives/2411
《JupyterLab初体验》有5条留言
前一篇:Email批量发送工资条的方案
后一篇:(含)中文字符串的对齐
©Copyright 麦新杰 Since 2019 Python笔记
jupyter自带nbconvert工具,可以将ipynb文件(就是一个json文件)转换成其它格式,html,pdf... [ ]
把cell修改为markdown,可直接输入latex语法,输出漂亮的数学表达式。 [ ]
在WSL中安装jupyter,启动位置在:~/.local/bin/juypter [ ]
还是设置一个softlink方便点:
[ ]没有图形界面的Linux系统,使用JupyterLab,也可以正常显示matplotlib制作的图片! [ ]