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

如何在JupyterLab Notebook中移除In[]与Out[]单元格标签?

How to Hide In[..]/Out[..] Prompts in Jupyter Notebooks (Keep Line Numbers)

Great question! I totally get wanting to clean up the notebook UI and avoid Git clutter from those prompts—they can really bloat diffs when cell order changes. Here are a few reliable ways to remove them while keeping your line numbers intact:

Solution 1: Custom CSS (Quick Fix for Classic Notebook)

This is the fastest way to hide prompts without messing with config files. Here's how:

  • Locate or create the custom.css file in your Jupyter profile folder. It’s usually at ~/.jupyter/custom/custom.css (create the custom directory if it doesn’t exist).
  • Add the following CSS code to hide both input and output prompts:
/* Hide input prompts (In[..]) */
div.input_area .prompt.input_prompt {
    display: none;
}

/* Hide output prompts (Out[..]) */
div.output_area .prompt.output_prompt {
    display: none;
}
  • Restart your Jupyter Notebook server for the changes to take effect. Your line numbers will stay visible since you already have lineNumbers:true enabled in your config.

Solution 2: Modify Jupyter Configuration File

If you prefer using Python-based config settings:

  • Generate the config file if you haven’t already by running this in your terminal:
jupyter notebook --generate-config
  • Open the generated file (typically ~/.jupyter/jupyter_notebook_config.py) in a text editor.
  • Add these lines to replace the prompts with empty strings (effectively hiding them):
# Remove input prompts
c.CodeCell.input_prompt = ''

# Remove output prompts
c.CodeCell.output_prompt = ''
  • Save the file and restart your notebook server. This will clean up the UI and eliminate Git diff noise from prompt number changes.

Solution 3: JupyterLab Settings (If Using JupyterLab)

If you’re using JupyterLab instead of the classic notebook:

  • Open the Advanced Settings Editor (click the gear icon in the left sidebar).
  • Select Notebook from the list of settings.
  • In the User Preferences tab, add this JSON snippet to hide prompts:
{
  "codeCellConfig": {
    "inputPrompt": "",
    "outputPrompt": ""
  }
}
  • Save the settings—changes will apply immediately. Your line numbers remain visible as configured.

All these methods will remove the In[..]/Out[..] prompts while preserving your line numbers. This should also fix the Git history issue since prompt numbers won’t change when you reorder or edit cells.

内容的提问来源于stack exchange,提问作者M.R.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 07:32:44