【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

相关推荐
站大爷IP4 分钟前
Python构建MCP服务器:从工具封装到AI集成的全流程实践
python
深盾安全2 小时前
Python 装饰器详解
python
前端小趴菜052 小时前
python - 数据类型转换
python
跟橙姐学代码2 小时前
学Python必须迈过的一道坎:类和对象到底是什么鬼?
前端·python
卡洛斯(编程版3 小时前
(1) 哈希表全思路-20天刷完Leetcode Hot 100计划
python·算法·leetcode
FreakStudio3 小时前
一文速通 Python 并行计算:教程总结
python·pycharm·嵌入式·面向对象·并行计算
群联云防护小杜3 小时前
从一次 DDoS 的“死亡回放”看现代攻击链的进化
开发语言·python·linq
Ice__Cai4 小时前
Flask 入门详解:从零开始构建 Web 应用
后端·python·flask·数据类型
霸敛4 小时前
好家园房产中介网后台管理完整(python+flask+mysql)
开发语言·python·flask
HenryLin4 小时前
SHAP值的核心概念
python