You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Jupyter Notebook中实现类似PyCharm或Visual Studio Code的代码自动补全功能?

How to Get PyCharm/VS Code-like Code Auto-Completion in Jupyter Notebook?

Awesome question—getting that snappy, context-aware auto-completion you’re used to in PyCharm or VS Code makes Jupyter Notebook workflows so much smoother. I’ve walked tons of developers through setting this up, so let’s cover the best methods, including the tool-based approach you spotted on YouTube.

1. Switch to Jupyter Lab (Built-In, No Fuss)

Honestly, if you haven’t tried Jupyter Lab yet, it’s the easiest win here. It’s the modern, more powerful cousin of the classic notebook, and it comes with IDE-level auto-completion built right in. It uses the same Language Server Protocol (LSP) that makes VS Code’s suggestions so smart—so you’ll get completions for variables, imported modules, function arguments, even docstring previews without any extra setup.

  • Install it with:
    pip install jupyterlab
    
  • Launch it with jupyter lab, and you’ll notice the auto-completion works just like your favorite IDEs from the get-go.

2. Add LSP Support to Classic Jupyter Notebook

If you’re attached to the classic notebook interface, you can still get that smart auto-completion by adding LSP extensions:

  • First, install the core Jupyter LSP package:
    pip install jupyter-lsp
    
  • Then install the language server for your preferred language (for Python, use the full-featured version):
    pip install python-lsp-server[all]
    
  • Restart your notebook server, and you’ll start seeing context-aware suggestions. You can tweak settings like trigger delay or which completion types show up via the notebook’s settings menu.

3. The AI-Powered Tool Method (What You Saw on YouTube)

Chances are the tutorial you watched used an AI-driven code completion tool that integrates seamlessly with Jupyter. The two most popular options are:

  • Kite: A widely used AI assistant that learns your coding style to offer personalized completions. Here’s how to set it up:
    1. Install the Kite desktop app (it runs in the background)
    2. Install the Jupyter Kite extension:
      pip install kite-jupyter
      
    3. Enable the extension in your notebook:
      jupyter nbextension enable --py kite_jupyter
      
    Once set up, Kite will pop up suggestions as you type, just like in PyCharm or VS Code.
  • TabNine: Another AI tool with multi-language support. Install its Jupyter extension with:
    pip install jupyter-tabnine
    
    Then enable it:
    jupyter nbextension install --py jupyter_tabnine
    jupyter nbextension enable --py jupyter_tabnine
    
    It analyzes your code patterns to offer relevant, time-saving completions.

Pro Tips to Boost Auto-Completion Reliability

  • Run your import cells first: Auto-completion relies on the kernel knowing which modules/variables are loaded—always execute your import cells before expecting suggestions for those modules.
  • Use proper docstrings: Adding detailed docstrings to your functions/classes will make auto-completion show useful parameter hints and descriptions, just like in IDEs.
  • Keep your packages updated: Outdated ipython or jupyter packages can break auto-completion. Run pip install --upgrade ipython jupyter to keep things working smoothly.

内容的提问来源于stack exchange,提问作者Jerem Moses

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 11:43:12