Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calls to input() should flush stdout when executing cells #13039

Open
MaddyGuthridge opened this issue Mar 9, 2023 · 11 comments
Open

Calls to input() should flush stdout when executing cells #13039

MaddyGuthridge opened this issue Mar 9, 2023 · 11 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel)
Milestone

Comments

@MaddyGuthridge
Copy link

MaddyGuthridge commented Mar 9, 2023

Environment data

  • VS Code version: 1.76.0
  • Jupyter Extension version (available under the Extensions sidebar): v2023.2.1000592019
  • Python Extension version (available under the Extensions sidebar): v2023.4.0
  • OS (Windows | Mac | Linux distro) and version: Fedora 37
  • Python and/or Anaconda version: Python 3.11.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Jupyter server running: Local

Expected behaviour

When I run a code block containing input and print functions, stdout is flushed whenever the input function is called, so that I can see the full output before typing my input.

Actual behaviour

The buffer only flushes once every 2 inputs on average, meaning that I often can't see the outputs of cells that I need to interact with.

Steps to reproduce:

Run a cell such as this:

while True:
    text = input("Enter some text")
    if text == '':
        print("Goodbye")
        break
    print(f"You entered {text}")

Observe that the print-out happens inconsistently.

This can be fixed by adding a hack such as the following, but it is extremely inconvenient for me to do this to all of the notebooks I need to work with.

import builtins

def input(*args, **kwargs):
    print(end='', flush=True)
    return builtins.input(*args, **kwargs)

Logs

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

Visual Studio Code (1.76.0, undefined, desktop)
Jupyter Extension Version: 2023.2.1000592019.
Python Extension Version: 2023.4.0.
Workspace folder /home/migue/Source/COMP/1010/course_dev/labs-dev
User belongs to experiment group 'jupyterEnhancedDataViewer'
User belongs to experiment group 'jupyterTestcf'
info 22:26:11.323: LSP Notebooks experiment is enabled
info 22:26:11.563: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m pip list
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m pip list
info 22:26:28.308: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd0ead52af248bf5110408d1f700d37b39ad1311078b7c85ad4052e3ecc15fa24dd./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python.-m#ipykernel_launcher (Python Path: /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv, EnvType: Venv, EnvName: '.venv', Version: 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]) for '/home/migue/Source/COMP/1010/course_dev/labs-dev/submissions/week_02/z5350586 - Chen Du.ipynb' (disableUI=false)
info 22:26:28.364: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 22:26:28.409: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"68be1631-a20b-4f9f-b446-734ba592b5f2" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053gMVMOvIdphcu.json
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"68be1631-a20b-4f9f-b446-734ba592b5f2" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053gMVMOvIdphcu.json
info 22:26:28.409: Process Execution: cwd: ~/Source/COMP/1010/course_dev/labs-dev/submissions/week_02
cwd: ~/Source/COMP/1010/course_dev/labs-dev/submissions/week_02
info 22:26:28.612: ipykernel version & path 6.21.1, ~/Source/COMP/1010/course_dev/labs-dev/.venv/lib64/python3.11/site-packages/ipykernel/__init__.py for /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python
warn 22:26:29.048: StdErr from Kernel Process 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

info 22:26:29.383: Started Kernel .venv (Python 3.11.2) (pid: 321765)
info 22:26:29.431: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.2.1000592019/pythonFiles/printJupyterDataDir.py
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.2.1000592019/pythonFiles/printJupyterDataDir.py
info 22:27:19.756: Interrupt kernel execution
info 22:27:19.757: Interrupt requested /home/migue/Source/COMP/1010/course_dev/labs-dev/submissions/week_02/z5350586 - Chen Du.ipynb
info 22:27:19.757: Interrupt kernel execution
info 22:27:19.757: Interrupting kernel: pythonjvsc74a57bd0ead52af248bf5110408d1f700d37b39ad1311078b7c85ad4052e3ecc15fa24dd
info 22:27:19.757: Interrupting kernel via SIGINT
info 22:27:20.006: Cancel all remaining cells true || Error || undefined
info 22:27:20.008: Interrupt requested & sent for /home/migue/Source/COMP/1010/course_dev/labs-dev/submissions/week_02/z5350586 - Chen Du.ipynb in notebookEditor.
info 22:34:17.907: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd0ead52af248bf5110408d1f700d37b39ad1311078b7c85ad4052e3ecc15fa24dd./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python.-m#ipykernel_launcher (Python Path: /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv, EnvType: Venv, EnvName: '.venv', Version: 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]) for '/home/migue/Source/COMP/1010/course_dev/labs-dev/submissions/week_02/z5183911 - Allison Chen.ipynb' (disableUI=false)
info 22:34:17.944: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m pip list
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m pip list
info 22:34:17.980: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 22:34:18.029: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9008 --control=9006 --hb=9005 --Session.signature_scheme="hmac-sha256" --Session.key=b"77d8a6d6-a8eb-4495-a236-cc39864256a3" --shell=9007 --transport="tcp" --iopub=9009 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053Q05n5hr1Mu0Q.json
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9008 --control=9006 --hb=9005 --Session.signature_scheme="hmac-sha256" --Session.key=b"77d8a6d6-a8eb-4495-a236-cc39864256a3" --shell=9007 --transport="tcp" --iopub=9009 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053Q05n5hr1Mu0Q.json
info 22:34:18.029: Process Execution: cwd: ~/Source/COMP/1010/course_dev/labs-dev/submissions/week_02
cwd: ~/Source/COMP/1010/course_dev/labs-dev/submissions/week_02
info 22:34:18.187: ipykernel version & path 6.21.1, ~/Source/COMP/1010/course_dev/labs-dev/.venv/lib64/python3.11/site-packages/ipykernel/__init__.py for /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python
warn 22:34:18.584: StdErr from Kernel Process 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

info 22:34:19.010: Started Kernel .venv (Python 3.11.2) (pid: 327329)
info 22:40:29.236: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd0ead52af248bf5110408d1f700d37b39ad1311078b7c85ad4052e3ecc15fa24dd./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python.-m#ipykernel_launcher (Python Path: /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv, EnvType: Venv, EnvName: '.venv', Version: 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]) for '/home/migue/Source/COMP/1010/course_dev/labs-dev/submissions/week_02/z5367167 - Michael Chiu.ipynb' (disableUI=false)
info 22:40:29.454: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m pip list
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m pip list
info 22:40:29.478: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 22:40:29.507: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9013 --control=9011 --hb=9010 --Session.signature_scheme="hmac-sha256" --Session.key=b"d8c21f46-85ec-4040-b8b5-84974f83eb6d" --shell=9012 --transport="tcp" --iopub=9014 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053ORaRFf5PO20w.json
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9013 --control=9011 --hb=9010 --Session.signature_scheme="hmac-sha256" --Session.key=b"d8c21f46-85ec-4040-b8b5-84974f83eb6d" --shell=9012 --transport="tcp" --iopub=9014 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053ORaRFf5PO20w.json
info 22:40:29.507: Process Execution: cwd: ~/Source/COMP/1010/course_dev/labs-dev/submissions/week_02
cwd: ~/Source/COMP/1010/course_dev/labs-dev/submissions/week_02
info 22:40:29.701: ipykernel version & path 6.21.1, ~/Source/COMP/1010/course_dev/labs-dev/.venv/lib64/python3.11/site-packages/ipykernel/__init__.py for /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python
warn 22:40:30.088: StdErr from Kernel Process 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

info 22:40:30.384: Started Kernel .venv (Python 3.11.2) (pid: 331736)
info 22:42:23.003: Cancel all remaining cells true || Error || undefined
info 22:43:34.878: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd0ead52af248bf5110408d1f700d37b39ad1311078b7c85ad4052e3ecc15fa24dd./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python.-m#ipykernel_launcher (Python Path: /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv, EnvType: Venv, EnvName: '.venv', Version: 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]) for '/home/migue/Source/COMP/1010/course_dev/labs-dev/submissions/week_02/z5440815 - Clara Davila.ipynb' (disableUI=false)
info 22:43:34.905: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 22:43:34.950: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9018 --control=9016 --hb=9015 --Session.signature_scheme="hmac-sha256" --Session.key=b"bce614b4-7683-40c7-b8fe-d3860d6d400a" --shell=9017 --transport="tcp" --iopub=9019 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053hY07CZO6Hjkg.json
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9018 --control=9016 --hb=9015 --Session.signature_scheme="hmac-sha256" --Session.key=b"bce614b4-7683-40c7-b8fe-d3860d6d400a" --shell=9017 --transport="tcp" --iopub=9019 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053hY07CZO6Hjkg.json
info 22:43:34.950: Process Execution: cwd: ~/Source/COMP/1010/course_dev/labs-dev/submissions/week_02
cwd: ~/Source/COMP/1010/course_dev/labs-dev/submissions/week_02
info 22:43:35.115: ipykernel version & path 6.21.1, ~/Source/COMP/1010/course_dev/labs-dev/.venv/lib64/python3.11/site-packages/ipykernel/__init__.py for /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python
warn 22:43:35.451: StdErr from Kernel Process 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

warn 22:43:35.518: StdErr from Kernel Process /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/lib64/python3.11/site-packages/traitlets/traitlets.py:2548: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(

warn 22:43:35.518: StdErr from Kernel Process /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/lib64/python3.11/site-packages/traitlets/traitlets.py:2499: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use 'bce614b4-7683-40c7-b8fe-d3860d6d400a' instead of 'b"bce614b4-7683-40c7-b8fe-d3860d6d400a"'.
  warn(

info 22:43:35.576: Started Kernel .venv (Python 3.11.2) (pid: 333922)
info 22:49:23.643: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd0ead52af248bf5110408d1f700d37b39ad1311078b7c85ad4052e3ecc15fa24dd./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python./home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/python.-m#ipykernel_launcher (Python Path: /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv, EnvType: Venv, EnvName: '.venv', Version: 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]) for '/home/migue/Source/COMP/1010/course_dev/labs-dev/demo.ipynb' (disableUI=false)
info 22:49:23.681: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 22:49:23.727: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m pip list
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m pip list
info 22:49:23.789: Process Execution: > ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9023 --control=9021 --hb=9020 --Session.signature_scheme="hmac-sha256" --Session.key=b"72c04cea-9778-48c4-961f-a9097e5c34a6" --shell=9022 --transport="tcp" --iopub=9024 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053MXxvGS4USgZ3.json
> ~/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9023 --control=9021 --hb=9020 --Session.signature_scheme="hmac-sha256" --Session.key=b"72c04cea-9778-48c4-961f-a9097e5c34a6" --shell=9022 --transport="tcp" --iopub=9024 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-320053MXxvGS4USgZ3.json
info 22:49:23.789: Process Execution: cwd: ~/Source/COMP/1010/course_dev/labs-dev
cwd: ~/Source/COMP/1010/course_dev/labs-dev
info 22:49:23.870: ipykernel version & path 6.21.1, ~/Source/COMP/1010/course_dev/labs-dev/.venv/lib64/python3.11/site-packages/ipykernel/__init__.py for /home/migue/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python
warn 22:49:24.377: StdErr from Kernel Process 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

info 22:49:24.613: Started Kernel .venv (Python 3.11.2) (pid: 338014)
info 22:59:12.582: Interrupt kernel execution
info 22:59:12.583: Interrupt requested /home/migue/Source/COMP/1010/course_dev/labs-dev/demo.ipynb
info 22:59:12.583: Interrupt kernel execution
info 22:59:12.583: Interrupting kernel: pythonjvsc74a57bd0ead52af248bf5110408d1f700d37b39ad1311078b7c85ad4052e3ecc15fa24dd
info 22:59:12.583: Interrupting kernel via SIGINT
info 22:59:14.578: Cancel all remaining cells true || Error || undefined
info 22:59:14.579: Interrupt requested & sent for /home/migue/Source/COMP/1010/course_dev/labs-dev/demo.ipynb in notebookEditor.

@MaddyGuthridge MaddyGuthridge added the bug Issue identified by VS Code Team member as probable bug label Mar 9, 2023
@DonJayamanne DonJayamanne assigned DonJayamanne and unassigned rebornix Mar 9, 2023
@DonJayamanne DonJayamanne added the info-needed Issue requires more information from poster label Mar 9, 2023
@DonJayamanne
Copy link
Contributor

@MiguelGuthridge please could you try this in Jupyter Notebook (outside vscode)
and let me know whether you get the same behaviour there too?
If its the same, please let me know the version of Jupyter Notebook you are using as well (you can use python -m jupyter --version or jupyter --version

@MaddyGuthridge
Copy link
Author

Thanks, I've tried this in notebook, and it worked correctly. It also works correctly in Google Colab. This appears to be an issue with VS Code in particular.
image

Here's my version information:

Selected Jupyter core packages...
IPython          : 8.9.0
ipykernel        : 6.21.1
ipywidgets       : not installed
jupyter_client   : 8.0.2
jupyter_core     : 5.2.0
jupyter_server   : 2.4.0
jupyterlab       : not installed
nbclient         : 0.7.2
nbconvert        : 7.2.9
nbformat         : 5.7.3
notebook         : 6.5.3
qtconsole        : not installed
traitlets        : 5.9.0

@DonJayamanne
Copy link
Contributor

@MiguelGuthridge

  • I am unable to repro this issue, please could you share a screen recording of this issue
  • Please could you create a new environment and install the latest IPyhton and IPyKernel packages, possible its been fixed in these later versions.
  • Also, please could you try running the same code in jupyter notebook against this same environment
<full path>/Source/COMP/1010/course_dev/labs-dev/.venv/bin/python -m jupyter notebook,

Also based on the logs, you seem to be interrupting the cells, is that deliberate.

@MaddyGuthridge
Copy link
Author

MaddyGuthridge commented Mar 31, 2023

Here's a screen recording:

2023-03-31.16-57-51.mp4

The repo with the code is available here: https://github.com/MiguelGuthridge/testJupyter

It doesn't happen immediately in this case, but the issue is present after a few inputs. This was done in a brand new environment with the latest versions of all dependencies.

Here's my pip freeze output in that environment:

asttokens==2.2.1
backcall==0.2.0
comm==0.1.3
debugpy==1.6.6
decorator==5.1.1
executing==1.2.0
ipykernel==6.22.0
ipython==8.12.0
jedi==0.18.2
jupyter_client==8.1.0
jupyter_core==5.3.0
matplotlib-inline==0.1.6
nest-asyncio==1.5.6
packaging==23.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
platformdirs==3.2.0
prompt-toolkit==3.0.38
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.14.0
python-dateutil==2.8.2
pyzmq==25.0.2
six==1.16.0
stack-data==0.6.2
tornado==6.2
traitlets==5.9.0
wcwidth==0.2.6

@MaddyGuthridge
Copy link
Author

MaddyGuthridge commented Mar 31, 2023

Also here's the output for Jupyter for that session:

Note that at the top, the dependencies aren't installed - I installed them when prompted by VS Code.

Visual Studio Code (1.76.2, undefined, desktop)
Jupyter Extension Version: 2023.2.1200692131.
Python Extension Version: 2023.4.1.
Workspace folder /home/migue/Source/testJupyter
User belongs to experiment group 'jupyterEnhancedDataViewer'
User belongs to experiment group 'jupyterTestcf'
info 16:56:42.448: LSP Notebooks experiment is enabled
warn 16:56:43.272: Failed to get activated env vars with python /bin/python in 259ms
info 16:56:43.318: Process Execution: > /bin/python -c "import site;print("USER_BASE_VALUE");print(site.USER_SITE);print("USER_BASE_VALUE");"
> /bin/python -c "import site;print("USER_BASE_VALUE");print(site.USER_SITE);print("USER_BASE_VALUE");"
info 16:56:43.433: Process Execution: > /bin/python -m pip list
> /bin/python -m pip list
info 16:56:55.937: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9./home/migue/Source/testJupyter/.venv/python./home/migue/Source/testJupyter/.venv/python.-m#ipykernel_launcher (Python Path: /home/migue/Source/testJupyter/.venv, EnvType: Venv, EnvName: '.venv', Version: 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]) for '/home/migue/Source/testJupyter/example.ipynb' (disableUI=false)
info 16:56:56.032: Process Execution: > ~/Source/testJupyter/.venv/bin/python -m pip list
> ~/Source/testJupyter/.venv/bin/python -m pip list
info 16:56:56.054: Process Execution: > ~/Source/testJupyter/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/Source/testJupyter/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
warn 16:56:56.095: Stderr output when getting ipykernel version & path Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ipykernel' for /home/migue/Source/testJupyter/.venv/bin/python
info 16:56:56.134: Process Execution: > ~/Source/testJupyter/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"7c3ff502-be29-4e35-a8cc-0fab2c5f3f13" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-163533C5cssAo4lkGL.json
> ~/Source/testJupyter/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"7c3ff502-be29-4e35-a8cc-0fab2c5f3f13" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-163533C5cssAo4lkGL.json
info 16:56:56.134: Process Execution: cwd: ~/Source/testJupyter
cwd: ~/Source/testJupyter
warn 16:56:56.146: StdErr from Kernel Process /home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher

error 16:56:56.149: Disposing kernel process due to an error Ip [Error]: The kernel died. Error: /home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher... View Jupyter [log](command:jupyter.viewOutput) for further details.
    at ChildProcess.<anonymous> (/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/out/extension.node.js:17:90652)
    at ChildProcess.emit (node:events:538:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
  category: 'kerneldied',
  kernelConnectionMetadata: ea {
    kind: 'startUsingPythonInterpreter',
    kernelSpec: Yo {
      specFile: '/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/temp/jupyter/kernels/pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9/kernel.json',
      interpreterPath: '/home/migue/Source/testJupyter/.venv/bin/python',
      isRegisteredByVSC: 'registeredByNewVersionOfExt',
      name: 'pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9',
      argv: [Array],
      language: 'python',
      executable: 'python',
      display_name: '.venv',
      metadata: [Object],
      env: {},
      interrupt_mode: undefined
    },
    interpreter: {
      id: '/home/migue/Source/testJupyter/.venv/bin/python',
      sysPrefix: '/home/migue/Source/testJupyter/.venv',
      envPath: [f],
      displayPath: [f],
      envName: '.venv',
      uri: [f],
      displayName: '.venv',
      envType: 'Venv',
      version: [Object]
    },
    id: '.jvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9./home/migue/Source/testJupyter/.venv/python./home/migue/Source/testJupyter/.venv/python.-m#ipykernel_launcher'
  },
  exitCode: 1,
  stdErr: '/home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher\n'
}
error 16:56:56.152: /home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher

info 16:56:56.152: Dispose Kernel process 165652.
error 16:56:56.153: Kernel Launcher. launch, Class name = Vp, completed in 200ms, has a falsy return value, Arg 1: {"id":".jvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9./home/migue/Source/testJupyter/.venv/python./home/migue/Source/testJupyter/.venv/python.-m#ipykernel_launcher","kernelSpec":{"specFile":"/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/temp/jupyter/kernels/pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9/kernel.json","interpreterPath":"/home/migue/Source/testJupyter/.venv/bin/python","isRegisteredByVSC":"registeredByNewVersionOfExt","name":"pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9","argv":["python","-m","ipykernel_launcher","-f","{connection_file}"],"language":"python","executable":"python","display_name":".venv","metadata":{"interpreter":{"path":"/home/migue/Source/testJupyter/.venv/bin/python"}},"env":{}},"interpreter":{"id":"/home/migue/Source/testJupyter/.venv/bin/python","sysPrefix":"/home/migue/Source/testJupyter/.venv","envPath":"/home/migue/Source/testJupyter/.venv","displayPath":"/home/migue/Source/testJupyter/.venv","envName":".venv","displayName":".venv","envType":"Venv","version":{"major":3,"minor":11,"patch":2,"raw":"3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]"},"path":"/home/migue/Source/testJupyter/.venv/bin/python"},"kind":"startUsingPythonInterpreter"}, Arg 2: 60000, Arg 3: "~/Source/testJupyter/example.ipynb", Arg 4: "~/Source/testJupyter", Arg 5: <argument cannot be serialized for logging> Ip [Error]: The kernel died. Error: /home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher... View Jupyter [log](command:jupyter.viewOutput) for further details.
    at ChildProcess.<anonymous> (/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/out/extension.node.js:17:90652)
    at ChildProcess.emit (node:events:538:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
  category: 'kerneldied',
  kernelConnectionMetadata: ea {
    kind: 'startUsingPythonInterpreter',
    kernelSpec: Yo {
      specFile: '/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/temp/jupyter/kernels/pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9/kernel.json',
      interpreterPath: '/home/migue/Source/testJupyter/.venv/bin/python',
      isRegisteredByVSC: 'registeredByNewVersionOfExt',
      name: 'pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9',
      argv: [Array],
      language: 'python',
      executable: 'python',
      display_name: '.venv',
      metadata: [Object],
      env: {},
      interrupt_mode: undefined
    },
    interpreter: {
      id: '/home/migue/Source/testJupyter/.venv/bin/python',
      sysPrefix: '/home/migue/Source/testJupyter/.venv',
      envPath: [f],
      displayPath: [f],
      envName: '.venv',
      uri: [f],
      displayName: '.venv',
      envType: 'Venv',
      version: [Object]
    },
    id: '.jvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9./home/migue/Source/testJupyter/.venv/python./home/migue/Source/testJupyter/.venv/python.-m#ipykernel_launcher'
  },
  exitCode: 1,
  stdErr: '/home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher\n',
  vslsStack: [ CallSite {}, CallSite {}, CallSite {} ]
}
error 16:56:56.154: Failed to connect raw kernel session: Error: The kernel died. Error: /home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher... View Jupyter [log](command:jupyter.viewOutput) for further details.
warn 16:56:56.154: Error occurred while trying to start the kernel, options.disableUI=false Ip [Error]: The kernel died. Error: /home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher... View Jupyter [log](command:jupyter.viewOutput) for further details.
    at ChildProcess.<anonymous> (/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/out/extension.node.js:17:90652)
    at ChildProcess.emit (node:events:538:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
  category: 'kerneldied',
  kernelConnectionMetadata: ea {
    kind: 'startUsingPythonInterpreter',
    kernelSpec: Yo {
      specFile: '/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/temp/jupyter/kernels/pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9/kernel.json',
      interpreterPath: '/home/migue/Source/testJupyter/.venv/bin/python',
      isRegisteredByVSC: 'registeredByNewVersionOfExt',
      name: 'pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9',
      argv: [Array],
      language: 'python',
      executable: 'python',
      display_name: '.venv',
      metadata: [Object],
      env: {},
      interrupt_mode: undefined
    },
    interpreter: {
      id: '/home/migue/Source/testJupyter/.venv/bin/python',
      sysPrefix: '/home/migue/Source/testJupyter/.venv',
      envPath: [f],
      displayPath: [f],
      envName: '.venv',
      uri: [f],
      displayName: '.venv',
      envType: 'Venv',
      version: [Object]
    },
    id: '.jvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9./home/migue/Source/testJupyter/.venv/python./home/migue/Source/testJupyter/.venv/python.-m#ipykernel_launcher'
  },
  exitCode: 1,
  stdErr: '/home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher\n',
  vslsStack: [ CallSite {}, CallSite {}, CallSite {} ]
}
warn 16:56:56.155: Kernel Error, context = start Ip [Error]: The kernel died. Error: /home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher... View Jupyter [log](command:jupyter.viewOutput) for further details.
    at ChildProcess.<anonymous> (/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/out/extension.node.js:17:90652)
    at ChildProcess.emit (node:events:538:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
  category: 'kerneldied',
  kernelConnectionMetadata: ea {
    kind: 'startUsingPythonInterpreter',
    kernelSpec: Yo {
      specFile: '/home/migue/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/temp/jupyter/kernels/pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9/kernel.json',
      interpreterPath: '/home/migue/Source/testJupyter/.venv/bin/python',
      isRegisteredByVSC: 'registeredByNewVersionOfExt',
      name: 'pythonjvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9',
      argv: [Array],
      language: 'python',
      executable: 'python',
      display_name: '.venv',
      metadata: [Object],
      env: {},
      interrupt_mode: undefined
    },
    interpreter: {
      id: '/home/migue/Source/testJupyter/.venv/bin/python',
      sysPrefix: '/home/migue/Source/testJupyter/.venv',
      envPath: [f],
      displayPath: [f],
      envName: '.venv',
      uri: [f],
      displayName: '.venv',
      envType: 'Venv',
      version: [Object]
    },
    id: '.jvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9./home/migue/Source/testJupyter/.venv/python./home/migue/Source/testJupyter/.venv/python.-m#ipykernel_launcher'
  },
  exitCode: 1,
  stdErr: '/home/migue/Source/testJupyter/.venv/bin/python: No module named ipykernel_launcher\n',
  vslsStack: [ CallSite {}, CallSite {}, CallSite {} ]
}
info 16:56:56.177: Process Execution: > ~/Source/testJupyter/.venv/bin/python -c "import ipykernel;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
> ~/Source/testJupyter/.venv/bin/python -c "import ipykernel;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
info 16:56:56.190: installMissingDependencies /home/migue/Source/testJupyter/.venv/bin/python, ui.disabled=false for resource '/home/migue/Source/testJupyter/example.ipynb'
info 16:56:56.215: Process Execution: > ~/Source/testJupyter/.venv/bin/python -c "import ipykernel;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
> ~/Source/testJupyter/.venv/bin/python -c "import ipykernel;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
info 16:56:56.253: Process Execution: > ~/Source/testJupyter/.venv/bin/python -c "import pip;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
> ~/Source/testJupyter/.venv/bin/python -c "import pip;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
info 16:56:59.427: Process Execution: > ~/Source/testJupyter/.venv/bin/python -c "import pip;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
> ~/Source/testJupyter/.venv/bin/python -c "import pip;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
info 16:56:59.490: Process Execution: > ~/Source/testJupyter/.venv/bin/python -m pip install -U ipykernel
> ~/Source/testJupyter/.venv/bin/python -m pip install -U ipykernel
info 16:57:05.827: Process Execution: > ~/Source/testJupyter/.venv/bin/python -c "import ipykernel;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
> ~/Source/testJupyter/.venv/bin/python -c "import ipykernel;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
info 16:57:05.980: Dispose Kernel '/home/migue/Source/testJupyter/example.ipynb' associated with '/home/migue/Source/testJupyter/example.ipynb'
info 16:57:05.996: Process Execution: > ~/Source/testJupyter/.venv/bin/python -m pip list
> ~/Source/testJupyter/.venv/bin/python -m pip list
info 16:57:05.996: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd090267f21908a28b3126d4503a88c1074e428cd70bb13bea9e6d246a08553bad9./home/migue/Source/testJupyter/.venv/python./home/migue/Source/testJupyter/.venv/python.-m#ipykernel_launcher (Python Path: /home/migue/Source/testJupyter/.venv, EnvType: Venv, EnvName: '.venv', Version: 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]) for '/home/migue/Source/testJupyter/example.ipynb' (disableUI=false)
info 16:57:06.014: Process Execution: > ~/Source/testJupyter/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/Source/testJupyter/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 16:57:06.038: Process Execution: > ~/Source/testJupyter/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9011 --control=9009 --hb=9008 --Session.signature_scheme="hmac-sha256" --Session.key=b"c89cb212-dad2-4a36-984c-683070f7059f" --shell=9010 --transport="tcp" --iopub=9012 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-163533z7qVCsQYoFdK.json
> ~/Source/testJupyter/.venv/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9011 --control=9009 --hb=9008 --Session.signature_scheme="hmac-sha256" --Session.key=b"c89cb212-dad2-4a36-984c-683070f7059f" --shell=9010 --transport="tcp" --iopub=9012 --f=/home/migue/.local/share/jupyter/runtime/kernel-v2-163533z7qVCsQYoFdK.json
info 16:57:06.038: Process Execution: cwd: ~/Source/testJupyter
cwd: ~/Source/testJupyter
info 16:57:06.169: ipykernel version & path 6.22.0, ~/Source/testJupyter/.venv/lib64/python3.11/site-packages/ipykernel/__init__.py for /home/migue/Source/testJupyter/.venv/bin/python
warn 16:57:06.465: StdErr from Kernel Process 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

info 16:57:06.653: Started Kernel .venv (Python 3.11.2) (pid: 165783)

@DonJayamanne
Copy link
Contributor

Thanks for the logs, I was able to repro this issue once.

@MaddyGuthridge
Copy link
Author

Glad to hear it's not just me :) If there's anything else I can do to help, I'd love to do as much as I can

@DonJayamanne
Copy link
Contributor

Thanks, at this stage, there's nothing else we need,
Next step is to try and find the root cause and fix it

@DonJayamanne DonJayamanne added notebook-output notebook-kernel-execution and removed info-needed Issue requires more information from poster labels Apr 21, 2023
@DonJayamanne DonJayamanne added this to the Backlog milestone Dec 4, 2023
@DonJayamanne DonJayamanne added notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) and removed notebook-kernel-execution notebook-output labels Dec 14, 2023
@DonJayamanne
Copy link
Contributor

@MaddyGuthridge Please can you test this in the latest version of VS Code and Jupyter extension.
In the previous version we updated some of the Jupyter Lab packages that may have addressed this issue.
Please let me know, given that I could not replicate this at my end I cannot verify this, but believe it may have been fxied.

@DonJayamanne DonJayamanne added the info-needed Issue requires more information from poster label Dec 10, 2024
Copy link

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
@MaddyGuthridge
Copy link
Author

Hello, @DonJayamanne ! Sorry for the delayed reply. I can confirm that this is still an issue. Occasionally, lines are not printed before calls to input

@DonJayamanne DonJayamanne reopened this Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel)
Projects
None yet
Development

No branches or pull requests

3 participants