【python虚拟环境管理】使用conda安装jupyter、将conda环境写入notebook的kernel中

文章目录

  • [一. 什么是 jupyter](#一. 什么是 jupyter)
    • [1. jupyter notebook](#1. jupyter notebook)
    • [2. JupyterLab](#2. JupyterLab)
    • [3. Jupyter Kernel](#3. Jupyter Kernel)
  • [二. 使用conda安装Jupyter](#二. 使用conda安装Jupyter)
    • [1. 安装jupyter note](#1. 安装jupyter note)
    • [2. 将环境写入notebook的kernel中](#2. 将环境写入notebook的kernel中)
    • [3. Jupyter note运维命令](#3. Jupyter note运维命令)
    • [4. (可选)设置Jupyter 登录密码](#4. (可选)设置Jupyter 登录密码)
  • [三. jupyter note可视化界面操作](#三. jupyter note可视化界面操作)
    • [1. 使用notebook](#1. 使用notebook)
    • [2. 其他操作](#2. 其他操作)

一. 什么是 jupyter

1. jupyter notebook

jupyter notebook是一种 Web 应用,能让用户将说明文本、数学方程、代码和可视化内容全部组合到一个易于共享的文档中。它可以直接在代码旁写出叙述性文档,而不是另外编写单独的文档。也就是它可以能将代码、文档等这一切集中到一处,让用户一目了然。

  • Jupyter这个名字是它要服务的三种语言的缩写:Julia,PYThon和R,这个名字与"木星(jupiter)"谐音。
  • Jupyter Notebook 已迅速成为数据分析,机器学习的必备工具。因为它可以让数据分析师集中精力向用户解释整个分析过程。
  • 我们可以通过Jupyter notebook写出了我们的学习笔记。但是jupyter远远不止支持上面的三种语言,目前能够使用的语言他基本上都能支持,包括C、C++、C#,java、Go等等。

2. JupyterLab

JupyterLab是Jupyter项目的最新版本,它在Jupyter Notebook的基础上进行了改进和扩展:

  • JupyterLab提供了更现代化和灵活的用户界面,具有更好的可扩展性和集成性。
  • 与Jupyter Notebook不同,JupyterLab采用了标签页式的界面布局,允许用户在一个窗口中同时打开多个笔记本、编辑器和终端等组件。
  • JupyterLab支持更丰富的文件浏览器功能,用户可以直接在界面中浏览、创建和重命名文件。
  • JupyterLab还引入了集成的代码编辑器,具有语法高亮、自动完成和代码折叠等功能,使得编写和编辑代码更加便捷。
  • JupyterLab还提供了可定制的面板布局和主题样式,允许用户根据自己的喜好进行界面个性化设置。

3. Jupyter Kernel

Jupyter Kernel是一个计算引擎,它负责执行用户在Jupyter笔记本中输入的代码。 每个Kernel代表一种编程语言的运行环境。 例如,如果你在Jupyter笔记本中使用Python编写代码,那么你实际上是在Python Kernel下工作。 同样,对于R、Julia或其他语言,也有对应的Kernel。

二. 使用conda安装Jupyter

1. 安装jupyter note

python 复制代码
conda create --name jupyter_env

conda activate jupyter_env

python --version

# 安装
conda install jupyter notebook

# 终端方式启动
jupyter notebook --no-browser


# 页面方式启动
jupyter notebook

# http://127.0.0.1:8888/tree?token=cc54b360beace434410e4b8d8c6cf951fef64edc22c2212e

# [I 2024-07-15 16:04:03.283 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server

2. 将环境写入notebook的kernel中

  1. 将环境写入kernel中
shell 复制代码
# langchain-demo 是conda的虚拟环境
python -m ipykernel install --user --name=langchain-demo
  1. 选择新的kernel
  1. 调试执行

看到之前没有加载的依赖加载进来了。

3. Jupyter note运维命令

https://docs.jupyter.org/en/latest/running.html

4. (可选)设置Jupyter 登录密码

  1. 生成jupyter的配置文件:jupyter notebook --generate-config
  2. 控制台继续输入:jupyter notebook password (会输入两次密码,用来验证)
  3. 密码设置成功, 登录服务器: jupyter notebook

三. jupyter note可视化界面操作

1. 使用notebook

  1. 新建

  2. 编写与调试

2. 其他操作

https://cloud.tencent.com/developer/article/1091924

参考:

https://blog.csdn.net/qq_27825451/article/details/84427269

相关推荐
吕源林1 天前
C#怎么实现EF Core迁移 C#如何用Entity Framework Core进行数据库迁移和更新表结构【数据库】
jvm·数据库·python
qq_206901391 天前
JavaScript中箭头函数在对象字面量方法中的潜在错误
jvm·数据库·python
覆东流1 天前
第1天:Python环境搭建 & 第一个程序
开发语言·后端·python
m0_747854521 天前
如何为禁用按钮点击添加提示文案
jvm·数据库·python
2301_803538951 天前
CSS如何设计简洁的移动端底部固定导航_利用position-fixed实现
jvm·数据库·python
vegetablec1 天前
CSS如何制作卡片翻开呈现另一面的翻牌动画
jvm·数据库·python
吕源林1 天前
Golang怎么Redis发布订阅_Golang如何用Publish和Subscribe收发消息【实战】
jvm·数据库·python
用户8356290780511 天前
使用 Python 合并与拆分 Excel 单元格的实用方法
后端·python
2301_764150561 天前
Golang colly爬虫框架如何用_Golang colly教程【进阶】
jvm·数据库·python
2301_803538951 天前
SQL统计各分组中排名前三的记录_使用窗口函数RANK
jvm·数据库·python