栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

jupyter内切换conda环境配置

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jupyter内切换conda环境配置

一、先创造自己所需的conda环境

二、进入conda环境内,添加当前环境到jupyter内核
# 进入虚拟环境
activate tensorflow

# 安装jupyter 和 notebook
pip install jupyter notebook

#安装ipykernel,并进行相关操作
pip install --user ipykernel

#若想多个环境集成,--user必填。有这个选项后配置文件皆写入到当前用户目录下,不受环境切换影响
python -m ipykernel install --user --name= "想展示的名字"

# 查看jupyter是否已添加虚拟环境
jupyter kernelspec list
三、切换想配置进内核的环境,重复以下操作
# 退出上一个添加过的虚拟环境
conda deactivate

#进入想添加的环境
conda activate pytorch

# 安装jupyter 和 notebook(这一步可能能省掉,没有测试,不确定)
pip install jupyter notebook

#安装ipykernel,并进行相关操作
pip install --user ipykernel

#若想多个环境集成,--user必填。有这个选项后配置文件皆写入到当前用户目录下,不受环境切换影响
python -m ipykernel install --user --name= "想展示的名字"

# 查看jupyter是否已添加虚拟环境
jupyter kernelspec list
配置后的状态
(base) ubuntu@VM-4-4-ubuntu:~$ ls /home/ubuntu/.local/share/jupyter/kernels/
python3  tensorflow  test_env
(base) ubuntu@VM-4-4-ubuntu:~$ jupyter kernelspec list
Available kernels:
  python3       /home/ubuntu/.local/share/jupyter/kernels/python3
  tensorflow    /home/ubuntu/.local/share/jupyter/kernels/tensorflow
  test_env      /home/ubuntu/.local/share/jupyter/kernels/test_env
(base) ubuntu@VM-4-4-ubuntu:~$ cat /home/ubuntu/.local/share/jupyter/kernels/tensorflow/kernel.json
{
 "argv": [
  "/home/ubuntu/anaconda3/envs/tensorflow/bin/python",#这个路径即为conda虚拟环境所在的路径
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "tensorflow",
 "language": "python",
 "metadata": {
  "debugger": true
 }
}(base) ubuntu@VM-4-4-ubuntu:~$ 
 服务器端启用:
#进入任意某个安装好jupyter notebook的环境中
jupyter notebook --no-browser --ip=0.0.0.0 --port=8888
配置好的内核:

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1037702.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号