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.

Allow copying an image result from Python Interactive window

See original GitHub issue

Environment data

  • VS Code version: 1.30.2
  • Extension version (available under the Extensions sidebar): 2018.12.1
  • OS and version: Ubuntu 18.04
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.7.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions: None

Expected behaviour

It’d be great if Python plots within the IDE could be copied to the clipboard. I’d expect right-click to show a menu with “Copy” as an option, for example.

Copying pasting quick plots into Slack/e-mail is super convenient for sharing intermediate results with colleagues.

Actual behaviour

Copying code from Python Interactive works (including rich formatting), but copying images does not. Right-clicking on the image does not show a menu. Selecting the image as part of the surrounding code does not include the image.

Workaround: Take screenshot, paste into image editor, crop, copy-paste the crop, close image editor.

Steps to reproduce:

  1. Paste this into a .py script
#%%
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x))
  1. Click “Run Cell” in the editor.
  2. Try to copy the resulting plot to the clipboard.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:44
  • Comments:32 (15 by maintainers)

github_iconTop GitHub Comments

24reactions
bpopscommented, Sep 13, 2021

I didn’t want to create a new issue, but it appears some of the functionality discussed herein is further broken in the new vs code notebooks. Also, my main way of using plots before, dragging them out of vs code directly into powerpoint, no longer works. I must drag them into a windows explorer folder and then into powerpoint.

5reactions
andreimargeloiucommented, Jan 18, 2021

It’s 2021, it would be good to be able to copy the figures from the interactive figure viewer…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python interactive window (REPL) - Visual Studio
First, switch to the Python Environments window (View > Other Windows > Python Environments or Ctrl+K > Ctrl+`) and select the Open Interactive...
Read more >
How to save images from Python Interactive tab in Microsoft ...
But the answer here is that we don't have a way to do this currently. You can highlight it in the interactive window...
Read more >
Working with Jupyter code cells in the Python Interactive window
Working with Jupyter code cells in the Python Interactive window. ... with the token typically appears in the terminal output from where you...
Read more >
Chapter 17 – Manipulating Images
Figure 17-3 is the image that will be used for all the interactive shell ... Despite their names, the copy() and paste() methods...
Read more >
Changelog — Python 3.11.1 documentation
gh-95191: Include prompts when saving Shell (interactive input and output). gh-95511: Fix the Shell context menu copy-with-prompts bug of copying an extra line ......
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