question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vscode-jupyter changes cells that were not modified: removes \n at the end of every "image/png" field

See original GitHub issue

Environment data

  • VS Code version: Version: 1.61.1, commit c13f1abb110fc756f9b3a6f16670df9cd9d4cf63
  • Jupyter Extension version (available under the Extensions sidebar): v2021.9.1101343141
  • Python Extension version (available under the Extensions sidebar): v2021.10.1336267007
  • OS (Windows | Mac | Linux distro) and version: OS: Darwin x64 19.6.0
  • Python and/or Anaconda version: 3.8.12
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Jupyter server running: Local

Expected behaviour

When opening in VSCode a Jupyter notebook created using Jupyter Notebook or Jupyter Lab and making a tiny change to one cell, then saving the notebook, the other cells in the notebook should not be modified.

Actual behaviour

Every cell that outputs an image (e.g., using Matplotlib) is modified. Specifically, the \n at the end of every "image/png" field is removed. This makes switching between VSCode and Jupyter Notebook/Lab very painful, especially when working with git, as even minor changes lead to large diffs.

Steps to reproduce:

  1. Create a notebook with Jupyter Notebook or Jupyter Lab, and run the following code:
import matplotlib.pyplot as plt

plt.plot([1,2,3], [3, 1, 2])
plt.show()
  1. Save the notebook. You can verify that the "image/png" field has a \n at the end.
  2. Open the notebook in VScode, make a tiny modification without running the notebook or modifying the existing cells (e.g., add a markdown cell).
  3. Save the notebook. You can verify that the "image/png" field no longer has a \n at the end. It was modified even though we didn’t touch it.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rchiodocommented, Oct 27, 2021

I was looking at it because it was unassigned. Here’s a start: https://github.com/rchiodo/vscode/commit/8acd26407529bfa338732e5e3664e39723e1d795

1reaction
DonJayamannecommented, Oct 18, 2021

Thanks for filing this issue, i’ll look into this and am certain we can get this sorted out. Apologies this causes issues with your workflow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

January 2022 (version 1.64) - Visual Studio Code
We made some changes to make it more obvious when a cell is executing, and which cell is executing. First, when a cell...
Read more >
11 Practical Tips You Need to Know to Personalize Jupyter ...
If you want to try a new taste in running your python code in Jupyter Notebook (hereafter; Jupyter), you can change and personalize...
Read more >
Advanced Visual Studio Code for Python Developers
As a Python developer, a lot of the commands you'll use in Visual Studio Code are provided from extensions, similar to the Python...
Read more >
Inserting image into IPython notebook markdown
I found it helpful to just use the notebook insert image - which added the image as an attachment (which is now portable)....
Read more >
Documentation Style Guide - GitLab Docs
The GitLab documentation is not localized, but we follow guidelines that help benefit ... check that all documentation PNG images have been compressed:....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found