Jupyter lab 配置两个python环境

要在 Jupyter Lab 的 Launcher 中显示多个 Python 版本(比如你说的 Python 3.13 和 Python 3.9),你需要为每个版本分别创建 kernel(内核),并将它们注册到 Jupyter 中。下面是详细步骤(以 Windows 为例):


✅ 第一步:确保两个版本都已安装

先找到python位置

bash 复制代码
where python

确保你已经分别安装了 Python 3.13 和 Python 3.9,并知道它们的路径,比如:

  • Python 3.13: C:\Python313
  • Python 3.9: C:\Python39

你可以分别用这两个命令确认版本是否可用:

bash 复制代码
C:\Python313\python.exe --version
C:\Python39\python.exe --version

✅ 第二步:为每个 Python 安装 ipykernel

你需要为每个 Python 版本安装 ipykernel 包。

(1)给 Python 3.13 装:
bash 复制代码
C:\Python313\python.exe -m pip install ipykernel
(2)给 Python 3.9 装:
bash 复制代码
C:\Python39\python.exe -m pip install ipykernel

✅ 第三步:将两个 Python 注册为 Jupyter 内核

(1)注册 Python 3.13 为一个 kernel(可命名为 python313):
bash 复制代码
C:\Python313\python.exe -m ipykernel install --user --name python313 --display-name "Python 3.13"
(2)注册 Python 3.9 为一个 kernel(可命名为 python39):
bash 复制代码
C:\Python39\python.exe -m ipykernel install --user --name python39 --display-name "Python 3.9"

✅ 第四步:启动 Jupyter Lab 查看

现在你可以用以下命令启动 Jupyter Lab:

bash 复制代码
jupyter lab

在 Launcher 中的 Notebook 区域,你就会看到:

  • Python 3.13
  • Python 3.9

两个内核都可以选择启动 Notebook。


🔄 可选:移除不需要的内核

如果你以后不想显示其中某个内核了,可以用以下命令删除它:

bash 复制代码
jupyter kernelspec uninstall python313

或者:

bash 复制代码
jupyter kernelspec uninstall python39

如你还有使用 Anaconda 或虚拟环境,我也可以教你如何在 conda env 中显示多个 Python notebook 内核。需要的话请告诉我你是否使用 conda。

相关推荐
默_笙5 天前
🍙 给每个请求过安检:FastAPI 是怎么把校验写进类型注解的
python
qq_426003965 天前
启动playwright录制codegen生成自动化测试脚本
python·自动化
虎头金猫5 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
长沙三为智能科技5 天前
家政小程序开发从0到上线:五阶段交付流程与验收清单
python
伞伞悦读5 天前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__
开发语言·python
只睡四小时6 天前
Canvas 弹道联机实战:700 行 + 固定时间步长
python·websocket·html5·游戏开发·canvas
奇思妙想聪明勤奋的小羊6 天前
DeepAgents第5章:子Agent 与上下文隔离—让 Agent学会委派
人工智能·python·学习·语言模型
lpfasd1236 天前
2026年第38周GitHub趋势周报
python·科技·github
IZero076 天前
Jev 与 Laya
python·语言模型