使用pip安装使用JupyterLab

Jupyterlab是一个基于Python的应用,内置Notebook可在浏览器中编辑运行Python代码,非常方便。

前面介绍过怎么在Docker下安装使用Jupyterlab,这里讲下怎么通过pip直接安装。

为什么要直接安装而不是通过Docker运行?

  1. Host运行效率比虚拟机更高,资源占用更低
  2. 可以直接使用GPU加速ML/DL开发,如CUDA或MPS

安装步骤如下:

安装jupyterlab

pip3 install jupyterlab

生成配置文件

jupyter notebook --generate-config

输出Writing default config to: /Users/rhonin/.jupyter/jupyter_notebook_config.py

修改笔记本位置

修改上一步产生的配置文件,注释掉c.NotebookApp.notebook_dir,并修改其目录,注意要用绝对路径。

其它配置

c.NotebookApp.port #默认端口

启动笔记本

jupyter lab

默认的登录密码可在控制台输入出找到,关键词token

如果出现如下错误

JupyterLab Error

JupyterLab application assets not found in "/opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/share/jupyter/lab"

Please run `jupyter lab build` or use a different app directory

则需要先安装nodejs,再运行jupyter lab build,再重新执行jupyter lab即可。

Leave a Comment

豫ICP备19001387号-1