Jupyter notebook 最简安装方法

几种 Jupyter notebook 安装形式的特点

  • Jupyter 所能提供的智能提示非常有限, 因为它仅仅以来Inspect的实现, 对于未引入的package, 未被执行的cell, 函数参数类型推测无能为力.
  • Jupter Lab 引入了LSP, 使用跨进程的LSP server, 部分地改善了智能补全, 加速了智能提示的反应速度, 但改善程度优先, 缺少IDE那种大型项目所需的多文件管理能力.
  • vs code Jupyter 插件: 它提供了IDE级别的智能补全, 可以扫描虚拟环境级+项目级的类库和源码, 而且采用可在后台提早分析, 所以补全的效果和速度都更上一个层次.

原生 Jupyter 搭建Notebook环境

Jupyter notebook 可以在VS code安装, 也可以通过 python pip 来安装, 但最简单的方式还是使用 anaconda 安装.

快速安装 Jupyter notebook 的步骤

  • install anaconda
  • anaconda navigator: Home tab: install Jupyter notebook
  • anaconda navigator: env tab: create virtual env, name: py313_anacoda
  • anaconda navigator: env tab: switch to env: py313_anacoda
  • anaconda navigator: env tab: in run green arrow context menu, click open with jupyter notebook, 注意在 anaconda navigator Home tab 启动 Jupyter notebook总是不能很好直接进入notebook, 应该在 anaconda navigator env tab启动进入

启用代码补全功能

使用 Jupyter Lab, 再配合 Jupyter-LSP 会有较好的代码补全功能, 包括函数签名提示、类型检查等。 需要安装如下类库。 重启 Jupyter server后, 它会在后台启动一个 Python 语言服务器, 提供代码补全功能.

···bash
pip install jupyterlab-lsp python-lsp-server[all]
···

VScode + Jupyter 插件搭建Notebook环境

步骤:

  1. 操作系统安装Python解释器: Anaconda

  2. Python 环境中安装 Jupyter Kernel
    使用 Anaconda navigator 安装一个虚拟环境, 并在其中安装 Jupyter, 其实 VS code 的Jupyter插件要求虚拟环境安装 IPython 即可, 为了方便, 我直接安装 Jupyter.

  3. 安装数据分析和数据科学常用的类库
    pip install pandas-stubs # 为 pandas 提供 stub 提示
    pip install matplotlab/pandas/sklearn/numpy/scipy/seaborn

  4. 安装 vs code extension:

  • Python
  • Jupyter
  • Jupyter Keymap
  • Jupyter Cell Tags
  • Jupyter Slide Show
  • Jupyter Notebook Renderers
  • Jupyter PowerToys
  • Notebook Git Diff
  • Ruff , linter and format
posted @ 2026-05-24 20:59  harrychinese  阅读(45)  评论(0)    收藏  举报