【学习心得】Jupyter 如何在conda的base环境中其他虚拟环境内核

如果你在conda的base环境运行了jupyter lab打开了一个ipynb文本,此时选择的内核是base虚拟环境的Python内核,如果我想切换成其他conda虚拟环境来运行这个文件该怎么办?下面我们试着还原一下问题,并且解决问题。

【注】 这个问题出现在算力云平台上,用jupyter打开使用的是base环境内核,为了节约大家时间,直接说答案:安装nb_conda_kernels库

(1)问题复现

1、使用conda创建python虚拟环境

bash 复制代码
conda create -n env_name python=3.10 -y

2、激活进入虚拟环境后安装一个numpy用来测试

bash 复制代码
conda activate env_name

pip install numpy

【注】此时base环境没有numpy,只有env_name中有numpy

3、在base环境中安装jupyter lab

bash 复制代码
# 退出到base环境
conda deactivate

# 安装jupyterlab
pip install jupyterlab

# 打开jupyterlab
jupyter lab

4、测试一下内核是不是base里面的Python内核

【注】问题来了,我在base环境中想切换别的虚拟环境的内核该怎么办?

(2)解决问题

5、进入到base环境中安装nb_conda_kernels库

bash 复制代码
conda install nb_conda_kernels

(3)AutoDL中测试

1、打开一个云算力服务器的jupyter lab

2、进入终端去安装nb_conda_kernels

3、安装好之后,关机重启再进入jupyter lab

相关推荐
花酒锄作田14 小时前
使用 pkgutil 实现动态插件系统
python
前端付豪18 小时前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽19 小时前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战19 小时前
Pydantic配置管理最佳实践(一)
python
阿尔的代码屋1 天前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python
AI探索者2 天前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者2 天前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
FishCoderh2 天前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅2 天前
Python函数入门详解(定义+调用+参数)
python
曲幽2 天前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama