本文讲两件事,第一,如何安装在mac 上 安装 jupyter lab。 第二,如何向jupyter lab 中添加conda 虚拟环境
安装jupyter lab
安装
pip3 install jupyterlab
启动
jupyter-lab
启动后日志显示浏览器访问路径
[I 2022-05-08 15:51:41.754 ServerApp] http://localhost:8888/lab
添加虚环境到jupyterlab
将已有的conda 虚拟环境添加jupyter lab
列出所有虚环境
conda info -e
比如我有一个装好pytorch的虚拟环境叫 pytorch
在这个环境中安装 ipython内核
conda install -n pytorch ipykernel
进入这个环境,将当前环境写入 ipython内核
conda activate pytorch
python -m ipykernel install --user --name pytorch --display-name "pytorch"
可以在任意环境中启动jupyter-lab
可以在此切换虚拟环境
创建虚拟环境同时添加到 jupyterlab tensorflow 2.0
conda create -n tf2 python=3.7 ipykernel
conda activate tf2
python -m ipykernel install --user --name tf2 --display-name "tf2"
启动jupyter lab 后可以看到新的虚拟环境
tips
区别只在对已有的虚拟环境conda install ipykernel,还是 conda create 的同时安装ipykernel