当前位置: 首页 > news >正文

jupyter4.4安装使用

一、chrome谷歌浏览器

1. 安装

  • 1.1 下载地址:

下载地址: https://www.google.cn/intl/zh-CN_ALL/chrome/fallback/

2 插件markdown-viewer

  • 2.1 下载地址:

下载地址:https://github.com/simov/markdown-viewer/releases

  • 2.2 设置(打开mermaid渲染)
    • 【扩展程序】–>打开【开发者模式】
    • 【详情】–>【扩展程序选项】–>【Settings】打开:mermaid,mathjax

二、python安装(构建绿色版):

  1. 下载地址:https://mirrors.huaweicloud.com/python/3.13.3/

  2. 安装到 \path\to\Python3133

  3. 拷贝\path\to\Python3133 到\path\to\Python3133_bak

  4. 卸载python3.13.3

  5. 拷贝\path\to\Python3133_bak 到\path\to\Python3133

  6. 添加环境变量:\path\to\Python3133\Scripts和\path\to\Python3133到PATH

  7. 在\path\to\Python3133添加两个文件python3.13.3.bat 和 python3133.bat,内容如下:

    @echo off
    echo 原始命令:%~f0 %*
    echo 运行命令:%~d0%~p0python.exe %*
    %~d0%~p0python.exe %*
    
  8. 在\path\to\Python3133添加两个文件python3.13.3.sh 和 python3133.sh,内容如下:

    base_dir=$(cd $(dirname $0);pwd)
    echo 原始命令:$0 $*
    echo 运行命令:${base_dir}/python.exe $*
    ${base_dir}/python.exe $*
    
  9. 在\path\to\Python3133\Scripts添加两个文件pip3.13.3.bat 和 pip3133.bat,内容如下:

    @echo off
    echo 原始命令:%~f0 %*
    echo 运行命令:%~d0%~p0pip.exe %*
    %~d0%~p0pip.exe %*
    
  10. 在\path\to\Python3133\Scripts添加两个文件pip3.13.3.sh 和 pip3133.sh,内容如下:

    base_dir=$(cd $(dirname $0);pwd)
    echo 原始命令:$0 $*
    echo 运行命令:${base_dir}/pip.exe $*
    ${base_dir}/pip.exe $*
    
  11. 测试:

    • 在cmd窗口中
      python3.13.3 --version
      pip3133 --version
      
    • 在gitbash窗口中
      python3.13.3.sh --version
      pip3133.sh --version
      

三、安装jupyter

  1. 创建虚拟环境

    • cmd窗口
      mkdir .\my_jupyter
      cd .\my_jupyter
      
      python3.13.3 -m venv jupyter_venv
      .\jupyter_venv\Scripts\activate
      pip install requests
      deactivate
      
    • Git Bash窗口
      cd path/to/your/project
      mkdir ./my_jupyter
      python3.13.3.sh -m venv jupyter_venv
      
      source ./jupyter_venv/Scripts/activate
      pip install requests
      deactivate
      
  2. 安装jupyterlab

    • 相关网址:
      • github
      • 官网
      • https://github.com/jupyter/jupyter-packaging
    • 安装:
      pip install jupyterlab
      
  3. 汉化:

    • 相关网址:
      • https://github.com/jupyterlab/language-packs/releases
    • 安装:
      pip install jupyterlab-language-pack-zh-CN
      
    • 设置:
      【Settings】–>【Language】–>【Chinese (simplified, China)】
  4. 插件:

    • 相关网址:

      • https://github.com/jupyter-lsp/jupyterlab-lsp
    • 安装:

      pip install jupyterlab-lsp
      pip install python-lsp-server
      pip install "python-lsp-server[all]"
      pip install jupyterlab-spreadsheet-editor
      pip install jupyterlab-spreadsheet
      pip install jupyterlab_iframe
      pip install jupyterlab-code-formatter
      pip install jupyterlab_execute_time
      pip install bash_kernel
      pip install jupyterlab_myst
      pip install jupyterlab-latex
      

四、插件:

  1. 可以直接安装的插件:
    pip install json-lsp
    pip install yaml-lsp
    pip install jupyterlab_sql_editor[all]
    pip install sshkernel
    pip install jupyterlite-xeus
    
    pip install metakernel==0.25.*
    pip install python-language-server[all]
    
  2. 两个相对成熟的官网插件:
    • https://jupyterlab-contrib.github.io/extensions.html
    • https://github.com/ml-tooling/best-of-jupyter#jupyterlab-extensions
  3. 插件管理
注意:如果没有出现插件选项卡,可以通过 setting–>Advanced Settings Editor–Extension Manager :在User Overrides 添加语句{“enabled”: true},最后保存,就可以出现插件选项
当然,你也可以使用命令行方式进行插件的查看、安装、更新和删除

查看已安装插件:jupyter labextension list
更新已安装插件:jupyter labextension update --all
安装插件toc:jupyter labextension install @jupyterlab/toc
删除插件toc:jupyter labextension uninstall @jupyterlab/toc
  1. 常用插件
# 大部分不适用于 jupyter-lab 4.4,止步于jupyter-lab  3.4
REM 安装matplotlib 插件
pip install ipympl
pip install npm
pip install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib

REM 安装lsp插件
pip install jupyter-lsp
pip install python-lsp-server[all]
pip install python-language-server[all]
jupyter labextension install @krassowski/jupyterlab-lsp

REM 安装code formatter 插件
pip install jupyterlab_code_formatter
jupyter labextension install @ryantam626/jupyterlab_code_formatter
pip install black isort


REM jupyterlab-toc帮助我们在notebook界面利用markdown来创建目录,辅助我们更好地整合梳理数据分析工作流
jupyter labextension install @jupyterlab/toc

jupyter labextension install @jupyterlab/debugger-extension

REM 在jupyter lab中进行debug
jupyter labextension install @jupyterlab/debugger

REM jupyterlab-drawio是一个让我们可以在jupyter lab界面内基于drawio绘制流程图、思维导图等示意图的插件
jupyter labextension install jupyterlab-drawio

REM jupyter-matplotlib帮助我们在notebook界面配合matplotlib实现交互式的作图,只需要在绘图之前执行魔法命令%matplotlib widget,之后绘制的所有matplotlib图表即可自动转换为交互式的
pip install ipympl
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib

REM jupyterlab-execute-time插件帮助我们在jupyter lab中记录每个单元cell的执行开始以及运行耗时
jupyter labextension install jupyterlab-execute-time

REM jupyterlab-plotly是一款帮助plotly图像在jupyter lab中正常渲染的插件
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget

REM jupyterlab-spreadsheet帮助我们在jupyter lab中查看表格类文件,特别是其支持查看多工作表的excel表格文件
jupyter labextension install jupyterlab-spreadsheet

REM jupyterlab-system-monitor通过在jupyter lab界面中添加资源监视器部件,能帮助我们在工作过程中方便的看到CPU、内存的实时占用情况:
pip install nbresuse
jupyter labextension install jupyterlab-topbar-extension jupyterlab-system-monitor

REM 通过使用在JupyterLab中添加对markdown的其他渲染支持 markdown-it,以及以下内容 插件
pip install jupyterlab_markup
jupyter labextension install @agoose77/jupyterlab-markup

pip install jupyterlab_latex
jupyter labextension install @mflevine/jupyterlab_html
pip install jupyterlab-dash
pip install jupyterlab-github

REM 该插件可以在Lab中展示plotly可视化效果。
pip install jupyterlab-fasta
pip install jupyterlab-geojson
pip install jupyterlab-katex
pip install jupyterlab-mathjax3
pip install jupyterlab-vega2
pip install jupyterlab-vega3
pip install jupyterlab-plotly

REM 该插件可以在Lab中展示bokeh可视化效果。
pip install jupyter_bokeh

REM 该插件可以在Lab中连接数据库,并进行sql查询和修改操作。会报错:The extension "jupyterlab-sql" is outdated
REM pip install jupyterlab_sql

  1. 代码自动提示完成
pip install jupyter-lsp
pip install python-lsp-server[all]
jupyter labextension install @krassowski/jupyterlab-lsp

五、安装java内核:

  1. 安装jdk(openjdk):
    • 官网:
      • https://openjdk.org/
      • https://jdk.java.net/archive/
      • https://adoptium.net/zh-CN/temurin/archive/?version=11
    • 下载版本:(11 GA (build 11+28) Windows 64-bit)
      • 地址:https://download.java.net/java/ga/jdk11/openjdk-11_windows-x64_bin.zip
    • 安装:
      将openjdk-11_windows-x64_bin.zip解压到指定目录:/path/to
  2. 安装ijava:
    • 官网:https://github.com/SpencerPark/IJava/releases
    • 解压:ijava-1.3.0.zip到\my_jupyter\packages目录下
    • 安装内核:
     cd /path/to/my_jupyter/packages/ijava-1.3.0
     python install.py --prefix=/path/to/my_jupyter/jupyter_venv
     jupyter kernelspec list
    
  3. 修改配置文件:
    • 文件:/path/to/my_jupyter\jupyter_venv\share\jupyter\kernels\java\kernel.json
    • 修改:将java指定其绝对路径(将\path\to换成自己的真实路径)
    • 内容示例如下:
    {
        "argv": [
            "\\path\\to\\jdk-11\\bin\\java",
            "-jar",
            "\\path\\to\\my_jupyter\\jupyter_venv\\share\\jupyter\\kernels\\java/ijava-1.3.0.jar",
            "{connection_file}"
        ],
        "display_name": "Java",
        "env": {},
        "interrupt_mode": "message",
        "language": "java"
    }
    

六、配置

1. 生成配置文件

jupyter lab --generate-config

存放路径:C:\Users%USERNAME%.jupyter\jupyter_lab_config.py

2. 生成并保存密码:

python -c "from jupyter_server.auth import passwd;print(passwd())"

3. 修改配置文件:

然后修改生成的配置文件 C:\Users%USERNAME%.jupyter\jupyter_lab_config.py 就可以了

c.ServerApp.allow_remote_access = False
c.ServerApp.open_browser = True
c.ServerApp.browser = 'C:/Program Files/Google/Chrome/Application/chrome.exe --app=%s'
c.ServerApp.root_dir = "/path/to/my_jupyter/jupyter_data"

c.ServerApp.ip = '0.0.0.0'
c.ServerApp.port = 8888

c.PasswordIdentityProvider.hashed_password = "argon2:$arg********A"
c.PasswordIdentityProvider.password_required = True

4. 将配置文件移动到自己的my_jupyter目录下

七、启动

1. 命令行启动

jupyter-lab --config=../jupyter_lab_config.py
\path\to\my_jupyter\jupyter_venv\Scripts\jupyter-lab.exe --config=\path\to\my_jupyter\jupyter_lab_config.py

2. 命令行指定root-dir

jupyter-lab --config=../jupyter_lab_config.py --notebook-dir=\path\to\my_jupyter\jupyter_data
\path\to\my_jupyter\jupyter_venv\Scripts\jupyter-lab.exe --config=\path\to\my_jupyter\jupyter_lab_config.py  --notebook-dir=\path\to\my_jupyter\jupyter_data

2. 桌面快捷方式

  • 2.1 创建jupyter-lab.exe快捷方式
  • 2.2 修改启动命令,添加参数: --config=\path\to\my_jupyter\jupyter_lab_config.py
  • 2.3 下载一个jupyter-lab图片,使用GIMP2导出为ico
  • 2.4 修改快捷方式的图标

3. 直接下载桌面应用

  • https://github.com/jupyterlab/jupyterlab-desktop

八、conda包转wheel包

pypi中无法安装的包(需要本地编译,例如y-py需要Rust语言环境),而conda中有编译好的包,
但是不是wheel,需要转换。所以本章节就处理这种包。

  1. 下载:

    • 官网:
    • 跳过注册:【Skip registration】
  2. 设置国内源

    # 清华源
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
    #设置搜索时显示通道地址
    conda config --set show_channel_urls yes
    
    # 中科大镜像源
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
     #设置搜索时显示通道地址
    conda config --set show_channel_urls yes
    
  3. 创建虚拟环境:

    cd /path/to/
    conda create --name conda_py312_venv python=3.12
    conda create --name conda_py313_venv python=3.13
    
    conda activate conda_py313_venv
    conda env list
    
    conda install y-py
    
    conda deactivate
    
  4. 打包环境:

    conda install -c conda-forge conda-pack
    conda pack -n conda_py313_venv -o conda_py313_venv.tar.gz
    
  5. 下载conda包:

    • 官网:https://anaconda.org/anaconda/y-py/files
  6. 将conda包转为wheel包(以y-py为例)

    • 下载对应的包:
      • 官网:https://anaconda.org/anaconda/y-py/files
      • 相应版本:win-64/y-py-0.6.2-py313h636fa0f_2.tar.bz2
      • 下载:地址
    • 解压(Git Bash):
      tar -xvjf y-py-0.6.2-py313h636fa0f_2.tar.bz2
      cd ./Lib/site-packages
      
    • 创建pyproject.toml文件
      [build-system]
      requires = ["setuptools", "wheel"]
      build-backend = "setuptools.build_meta"
      
      [project]
      name = "y-py"
      version = "0.6.2"
      
      [tool.setuptools.packages.find]
      exclude = ["build"]
      [tool.setuptools.package-data]
      "*" = ["*.pyd"]
      "y_py" = ["*.pyd"]
      
    • 打包为wheel
      pip install build wheel
      python -m build
      python -m build --wheel
      pip install dist\y_py-0.6.2-py3-none-any.whl
      
    • 安装测试:
      pip install dist\y_py-0.6.2-py3-none-any.whl
      
    • 验证:
      import y_py as Y
      d1 = Y.YDoc()
      print(d1)
      
  7. 其他包(下面两个包使用的是jupyter-lab3):

    conda install conda-forge::jupyterlab-markup
    conda install conda-forge::jupyterlab-drawio
    

© 著作权归作者所有

相关文章:

  • 器件封装-2025.4.13
  • 【李宏毅深度学习——回归模型的PyTorch架构】Homework 1:COVID-19 Cases Prediction (Regression)
  • 【深拷贝、浅拷贝】golang函数参数传递,变量复制后,操作变量参数,是否影响原有数据?全面解析
  • 软件设计的核心:从模块化到内聚与耦合
  • dify部署,ollama部署,拉取模型,创建ai聊天应用
  • 神经特征的统计度量及AI拓展
  • uniapp转换markdown
  • MySQL 常见存储引擎全解析:InnoDB、MyISAM、Memory 等对比与实战
  • 随笔 20250413 Elasticsearch 的 term 查询
  • 【UE5 C++课程系列笔记】35——HTTP基础——HTTP客户端异步请求API接口并解析响应的JSON
  • 【redis进阶三】分布式系统之主从复制结构(1)
  • deepseek微调环境配置
  • 如何对大模型进行优化,以提高其性能和效率?
  • 【计网】网络交换技术之分组交换(复习自用,重要1)
  • go语言学习笔记:gin + gorm + mysql 用户增删改查案例入门
  • 【Spring Boot 过滤器】
  • 中断的硬件框架
  • 【题解-洛谷】P2884 [USACO07MAR] Monthly Expense S
  • FreeBSD从14.1升级到14.2后桌面图标消失桌面背景消失且无法设置
  • 4.13日总结
  • 泽连斯基:将带领乌代表团前往土耳其,已准备好与普京会谈
  • 上海现有超12.3万名注册护士,本科及以上学历占一半
  • 青海规范旅游包车行为:不得引导外省籍旅游包车违规驻地运营
  • 《淮水竹亭》:一手好牌,为何打成这样
  • 金俊峰已跨区任上海金山区委副书记
  • 社恐也能嗨起来,《孤独摇滚》千人观影齐舞荧光棒