Jupyter Notebook输出自动换行失效,开启设置仍无效?
Jupyter Notebook输出无法自动换行问题排查与解决
问题情况
已在VS Code的settings.json中启用notebook.output.wordWrap: true配置,但Jupyter Notebook的输出仍未自动换行,配置内容如下:
{ "telemetry.telemetryLevel": "off", "security.workspace.trust.untrustedFiles": "open", "workbench.colorTheme": "Visual Studio Light", "python.defaultInterpreterPath": "/home/user/anaconda3/envs/myenv/bin/python", "editor.semanticHighlighting.enabled": false, "editor.occurrencesHighlight": "off", "editor.selectionHighlight": false, "editor.semanticTokenColorCustomizations": { }, "notebook.output.wordWrap": true, "editor.parameterHints.enabled": false, "workbench.settings.applyToAllProfiles": [ ] }
问题原因
这并非你的操作错误,而是一个曾存在的已知Bug:
- 此前已有其他用户反馈同类问题,该问题虽在代码库中完成修复,但一度未推送正式更新
- 最新说明:该Bug已在近期的VS Code/Jupyter扩展更新中修复
解决方案
- 更新到最新版本:将VS Code及Jupyter扩展更新至当前最新版本,更新完成后重启VS Code和Jupyter内核
- 临时替代方案(若暂无法更新):
- 在代码中对长文本手动添加换行符
\n - 使用文本处理逻辑拆分长输出内容后再打印
- 在代码中对长文本手动添加换行符
内容的提问来源于stack exchange,提问作者snapcrack
相关产品推荐
相关产品推荐

