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.

Native Notebooks - Cell output is rendered twice

See original GitHub issue

Environment data

  • VS Code version:
    Version: 1.53.0-insider (user setup)
    Commit: 76436a4d43566cd313629799e2ec51b4d00caa64
    Date: 2020-12-11T17:56:17.606Z
    Electron: 11.0.3
    Chrome: 87.0.4280.67
    Node.js: 12.18.3
    V8: 8.7.220.25-electron.0
    OS: Windows_NT x64 10.0.20277
    
  • Jupyter Extension version (available under the Extensions sidebar): 2020.12.414227025
  • Python Extension version (available under the Extensions sidebar): 2020.11.371526539, with Pylance 2020.12.2
  • OS (Windows | Mac | Linux distro) and version: Microsoft Windows 10.0.20277
  • Python and/or Anaconda version: Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
  • Jupyter server running: Local

Expected behaviour

The desired output is printed only once.

Actual behaviour

The desired output is printed twice (double/duplicated output).

Steps to reproduce

  1. Open Command Pattle, run command Jupyter: Create New Blank Jupyter Notebook.
  2. After the new notebook is opened, type something like 123 then press Shift + Enter. (Make sure you’re using Native Notebook Editor)
  3. You can see the output is 123123, which should be 123 only.

image

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

使用者屬於 "NativeNotebookEditor" 實驗性群組 (TRANSLATE: User is in the "NativeNotebookEditor" expermential group)
> c:\Users\xtyzw\Projects\d2l\d2l\Scripts\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py -c "import notebook"
> c:\Users\xtyzw\Projects\d2l\d2l\Scripts\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py -c "import jupyter"
> c:\Users\xtyzw\Projects\d2l\d2l\Scripts\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py jupyter kernelspec --version
> c:\Users\xtyzw\Projects\d2l\d2l\Scripts\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> c:\Users\xtyzw\Projects\d2l\d2l\Scripts\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> c:\Users\xtyzw\Projects\d2l\d2l\Scripts\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> dotnet interactive jupyter --default-kernel powershell ~\AppData\Local\Temp\tmp-1856zTmtrY8hNK7u.json
cwd: ~\AppData\Local\Programs\Microsoft VS Code Insiders
Started kernel .NET (PowerShell)
> dotnet interactive jupyter --default-kernel powershell ~\AppData\Local\Temp\tmp-1856sFWXll6dB1I9.json
cwd: ~\AppData\Local\Programs\Microsoft VS Code Insiders
Error 2020-12-12 13:33:53: Jupyter Kernel Spec not found for a local connection
> ~\AppData\Local\Microsoft\WindowsApps\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
> ~\AppData\Local\Microsoft\WindowsApps\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
Started kernel Python 3.9.0 64-bit
> ~\AppData\Local\Microsoft\WindowsApps\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
> ~\AppData\Local\Microsoft\WindowsApps\python.exe c:\Users\xtyzw\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v

Additional Information

  • The problem occurs in kernel Python, .NET (PowerShell), but not in .NET (C#). By inspecting the raw json file, you can see the reason is this problem only exists for type text/plain - and that’s true, change it to text/html then output only prints once.

    `Python` cell raw output

    "outputs": [
     {
      "data": {
       "text/plain": "123"
      },
      "execution_count": 1,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    

    `C#` cell raw output

    "outputs": [
     {
      "data": {
       "text/html": "<script type=\"text/javascript\">#!javascript\r\nif ((typeof(requirejs) !==  typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) { \r\n    let script = document.createElement(\"script\"); \r\n    script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\"); \r\n    script.onload = function(){\r\n        loadDotnetInteractiveApi();\r\n    };\r\n    document.getElementsByTagName(\"head\")[0].appendChild(script); \r\n}\r\nelse {\r\n    loadDotnetInteractiveApi();\r\n}\r\n\r\nfunction loadDotnetInteractiveApi(){\r\n    let apiRequire = requirejs.config({context:\"dotnet-interactive.1696.56005\",paths:{dotnetInteractive:\"http://localhost:56005/resources/dotnet-interactive\"}});\r\n    apiRequire(['dotnetInteractive'], \r\n    function(api) {       \r\n        api.createDotnetInteractiveClient(\"http://localhost:56005/\", window);\r\n    },\r\n    function(error){\r\n        console.log(error);\r\n    });\r\n}</script>"
      },
      "metadata": {
       "transient": {
        "display_id": "4b284a09-c6d1-4cce-ad12-8d2b03d59d0c"
       }
      },
      "output_type": "display_data"
     },
     {
      "data": {
       "text/html": "123"
      },
      "execution_count": 1,
      "metadata": {
       "transient": {
        "display_id": "0cf11c49-79dd-44de-b5a7-5d205967941c"
       }
      },
      "output_type": "execute_result"
     }
    ],
    

  • The problem doesn’t exists in either traditional notebook experience or jupyter webpage.

  • If you open the ipynb file with a text editor, you can see the output only once.

  • If you use developer tools to inspect the output, you can see the redundant output is in a span tag.

    <div class="output-plaintext">
       123
       <span><span class="">123</span></span>
    </div>
    
  • The issue may releated to https://github.com/microsoft/vscode-jupyter/issues/635.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:8

github_iconTop GitHub Comments

1reaction
gvanrossumcommented, Dec 19, 2020

It is, but I just checked for updates and found one, and now things are fixed. So sorry! Should have thought of that before (this is not the first time that happened… 😦 )

1reaction
DavidKutucommented, Dec 14, 2020

@KiruyaMomochi, another dev from the team can also repro consistently. We’ll follow the issue on the vscode repo. In the mean time you could use stable if possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jupyter notebook double output - Stack Overflow
I have a problem with double output! It irritates me. enter image description here. It happens with every output. Please help!
Read more >
Working with Jupyter Notebooks in Visual Studio Code
The segments in a JSON file are rendered as cells that are comprised of three components: input, output, and metadata. Comparing changes made...
Read more >
How VSCode has leaped forward as Jupyter Notebook Editor
Using the Notebooks API in VSCode, any cell's output plot can be saved as a file by a press of a button. It...
Read more >
Ten Simple Databricks Notebook Tips & Tricks for Data ...
Learn the latest tips and tricks for Databricks notebooks from the ... inline functionality is currently supported in notebook cells.
Read more >
jupyter notebook display bug for pandas dataframes ... - GitLab
Dataframes with double indexes displayed in jupyter notebooks can be ... The primary index cell is omitted in rows where the primary index ......
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