Jupyter Lab安装、配置、插件推荐、多用户使用教程

文章目录

  • Jupyter Lab安装和配置
    • 1.Jupyter Lab安装
    • 2.Jupyter Lab配置
    • 3. Jupyter Lab启动
    • 4. Jupyter Lab插件推荐
    • 5. Jupyter Lab多用户使用

Jupyter Lab安装和配置

1.Jupyter Lab安装

首先进入自己的Python环境或者其他Conda虚拟环境:

source activate XXXXXXX

然后在terminal或者cmd输入安装命令:

pip install jupyterlab
//或者
conda install -c conda-forge jupyterlab

等待安装完成!

2.Jupyter Lab配置

使用命令创建配置文件,其会生成C:\Users\用户名\.jupyter\jupyter_notebook_config.py或者/home/用户名/.jupyter/jupyter_notebook_config.py

jupyter lab --generate-config

使用编辑器打开配置文件,在文件上方添加:

c.ServerApp.ip = '*'
c.ServerApp.port = 8000
c.ServerApp.open_browser = False
c.ServerApp.root_dir = '/xxxx/xxxx/xxx' 
c.ServerApp.password_required = True
c.ServerApp.password = 'xxxxxxx'

其中ip代表允许访问的ip,*代表全部,port用于设置端口,open_browser用于设置启动lab时是否打开浏览器,root_dir用于设置lab启动文件夹根路径,password_required用于设置是否需要密码,password用于设置(加密)密码,这个加密密码的获取方式如下:

#打开python或者ipython环境

from notebook.auth import passwd
passwd()
#Enter password: 
#Verify password: 
#Out[2]: 'argon2:f704bjkasjdfkjasdjfkasjdkjfklmasjdfkalflakdkf'

复制上方输出的加密密码即可。

当然也可以在Terminal强制设置/修改密码:

jupyter lab password

更多配置可以查看默认配置文件下方的注释!

Jupyter Lab安装、配置、插件推荐、多用户使用教程_第1张图片

3. Jupyter Lab启动

在Terminal输入:

jupyter lab -p 9090 --no-browser

更多启动命名可通过jupyter lab --help查看,启动之后即可在浏览器输入:ip+端口 ,进行访问,如:127.0.0.0:9090。

Jupyter Lab安装、配置、插件推荐、多用户使用教程_第2张图片

4. Jupyter Lab插件推荐

首先启动Jupyter Lab,在Lab中打开菜单栏的Setting里的Advanced Setting Editor,接着找到Extension Manager,并在右边填入{'enabled':true}

Jupyter Lab安装、配置、插件推荐、多用户使用教程_第3张图片

然后即可在左边菜单栏找到插件安装符号,在里面就可以搜索插件,推荐如下:

Jupyter Lab安装、配置、插件推荐、多用户使用教程_第4张图片

  • theme-darcula:一个好看的主题配色
  • jupyterlab_go_to_definition:跳转到定义
  • jupyterlab_lsp:代码跳转+代码补全
  • 还有很多如:latex,git,html,plotly,bokeh,matplotlib,drawio等等

5. Jupyter Lab多用户使用

复制配置文件到指定位置,例如:

cp /home/admin555/.jupyter/jupyter_notebook_config.py /指定位置/jupyter_notebook_config.py

之后启动时,使用命令:

jupyter lab --config /指定位置/jupyter_notebook_config.py

你可能感兴趣的:(折腾记录,python,jupyter)