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

Kernel crashes when creating a matplotlib plot #15834

Closed
1 of 2 tasks
aldojacopovirno opened this issue Jul 8, 2024 · 23 comments
Closed
1 of 2 tasks

Kernel crashes when creating a matplotlib plot #15834

aldojacopovirno opened this issue Jul 8, 2024 · 23 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) notebook-output

Comments

@aldojacopovirno
Copy link

aldojacopovirno commented Jul 8, 2024

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

Error:
The Python 3.10.0 kernel in Jupyter Notebook continues to crash locally on my system. I have tried several solutions, including kernel restarts, code checks, and using a new virtual environment, but the issue persists. The detailed error message is as follows:

The kernel 'Python 3.10.0' died while executing code. Please check the kernel logs for more details.

Steps Tried:

  1. Restarting the Jupyter kernel.
  2. Checking Python code for syntax or logic errors.
  3. Creating and using a new Python virtual environment.
  4. Monitoring system resources to ensure there is sufficient available memory.
  5. Updating Jupyter and related extensions.

Additional Details:

  • The issue appears to be specific to my local environment, as the notebook runs correctly on other systems.
  • I have reviewed detailed kernel logs but have not found additional information to help resolve the issue.

Thank you for your assistance in resolving this problem.

VS Code Version

Version: 1.91.0

Jupyter Extension Version

v2024.6.0

Jupyter logs

[error] Error in execution (get message for cell) Error: The kernel 'Python 3.10.0' died. Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info. View Jupyter [log](command:jupyter.viewOutput) for further details.
    > Kernel Id = .jvsc74a57bd0aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49./usr/local/bin/python3./usr/local/bin/python3.-m#ipykernel_launcher
    > Interpreter Id = /usr/local/bin/python3
    > at n.verifyKernelState (/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-darwin-arm64/dist/extension.node.js:304:79702)
    > originalException = undefined

Coding Language and Runtime Version

Python v3.10.0

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

@aldojacopovirno aldojacopovirno added the bug Issue identified by VS Code Team member as probable bug label Jul 8, 2024
@DonJayamanne
Copy link
Contributor

Sorry for not getting back to you on this issue.

The issue appears to be specific to my local environment, as the notebook runs correctly on other systems.

This seems to be an issue with kernel dying due to external issues.
E.g. the code causes the kernel to crash instead of VS Code.
E.g. are you certain you are running the same notebook in the exact same Python environment. Its likely you aren't

VS Code doesn't really causes crashes, its the Python code that is running in the kernel thats causing the kernel to crash and thats actually beyond the control of VS Code.

Pelase can you try running the same notebook outside VS Code against the exact same Python environment and try again.

@DonJayamanne DonJayamanne added the info-needed Issue requires more information from poster label Jul 21, 2024
@xiezhipeng-git
Copy link

xiezhipeng-git commented Jul 23, 2024

@DonJayamanne
this error is Kernel error
My error info

Visual Studio Code (1.91.1, wsl, desktop)
Jupyter Extension Version: 2024.6.0.
Python Extension Version: 2024.10.0.
Pylance Extension Version: 2024.7.1.
Platform: linux (x64).
Workspace folder /my/work/kaggle_code/arc-agi/kaggle_arc_2024, Home = /home/xzpwsl2
14:42:36.830 [info] Starting Kernel (Python Path: /usr/bin/python3, Unknown, 3.10.12) for '
/my/work/kaggle_code/arc-agi/kaggle_arc_2024/arc24-visualization-compact.ipynb' (disableUI=true)
14:42:37.465 [warn] Failed to get activated env vars for /usr/bin/python3 in 636ms
14:42:37.466 [warn] Failed to get activated env vars for /usr/bin/python3 in 600ms
14:42:37.470 [info] Process Execution: /usr/bin/python3 -c "import site;print("USER_BASE_VALUE");print(site.USER_BASE);print("USER_BASE_VALUE");"
14:42:37.485 [error] Unable to determine site packages path for python /usr/bin/python3 (Unknown)
14:42:37.485 [error] Unable to determine site packages path for python /usr/bin/python3 (Unknown)
14:42:37.487 [info] Process Execution: /usr/bin/python3 -m pip list
14:42:37.488 [info] Process Execution: /usr/bin/python3 -c "import ipykernel; print(ipykernel.version); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.file)"
14:42:37.489 [info] Process Execution: /usr/bin/python3 -m ipykernel_launcher --f=/home//.local/share/jupyter/runtime/kernel-v2-19477TL83GuxBjphH.json
> cwd: //home/
/my/work/kaggle_code/arc-agi/kaggle_arc_2024
14:42:38.201 [info] Kernel successfully started
14:42:38.204 [info] Process Execution: /usr/bin/python3 /home/~/.vscode-server/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/pythonFiles/printJupyterDataDir.py
14:53:00.779 [error] Disposing session as kernel process died ExitCode: undefined, Reason:

This problem must arise.
Reproduce steps
Run ipynb within WSL
Run code within a cell.
The code has output and image output

import matplotlib.pyplot as plt
print and plt show

There are two questions now.
If there is no scheduled deletion of logs.
So when the output reaches 1000 lines, an error will be reported and the kernel will stop
The error willingness exceeds the maximum supported number of rows. Therefore, files are required. But the file address is illegal,because use wsl. Causing kernel errors here. And stop
So the function of scheduled deletion of logs was added.
So there was this mistake
This error occurs when logs and images are generated while deleting

@DonJayamanne
Copy link
Contributor

There are two questions now.
If there is no scheduled deletion of logs.
So when the output reaches 1000 lines, an error will be reported and the kernel will stop
The error willingness exceeds the maximum supported number of rows. Therefore, files are required. But the file address is illegal,because use wsl. Causing kernel errors here. And stop
So the function of scheduled deletion of logs was added.
So there was this mistake
This error occurs when logs and images are generated while deleting

I'm sorry however I am struggling to understand the problem now.
there's more information leads to me getting confused.

If there is no scheduled deletion of logs.
So when the output reaches 1000 lines, an error will be reported and the kernel will stop

What do you mean by this?

Can you try the following:

  • Create a new workspace folder
  • Create a new Python file
  • Run one cell with the following code
import matplotlib.pyplot as plt
plt.figure()
plt.plot([1,2], [1,2])
plt.show()

Does this work?

Given the fact taht you have mentioend about logs, scheduled deletion, eetc, I'm inclined to believe that this is caused by some code at your end.

Also, does this issue repro, when you use Jupyter Lab?

@xiezhipeng-git
Copy link

xiezhipeng-git commented Jul 29, 2024

@DonJayamanne
This is no problem. The problem is related to exceeding the maximum length and generating and deleting simultaneously.
Unfortunately, however. I am currently unable to access WSL.
Because of this issue microsoft/WSL#11849
I can't enter WSL at all now. I don't know if the files can be recovered.
The problem needs to be divided into two parts

  1. I didn't express myself clearly. Because I forgot to use Windows VSCode and WSL VSCode for the files in WSL, the result may be different.
    Specifically, problem one is opening the windows VSCode project in the WSL file path. Then any printed statements. If it exceeds 1000 lines (or possibly 5000 lines, I can't remember which one), an error will be reported. Then the Jupyter kernel terminates. There will be an error indicating that the file cannot be created. From the error message, it appears that this path is unique to Windows using WSI files. But when the file exceeds the maximum length of the Judge kernel, a file needs to be generated. But the generated failed in here.
    So, in order to solve this error, I introduced dynamic deletion of logs.

from IPython.display import clear_output
clear_output(wait=True)

  1. This method solves the above-mentioned errors that can cause kernel errors and prevent the program from continuing to run.
    But when I continue add plt related drawing code inside the output(hase the clear_ouput code,and more 5000 lines). The error mentioned in this article occurred
    If I only draw once, then the print statement will still be repeated many times. Because it will be cleared. After exceeding 5000 lines, there is no problem. Otherwise, if I print and draw together. This error occurs when there are a lot of printing times

@DonJayamanne
Copy link
Contributor

Thanks, but Still struggling to understand the issue , please can you share a very simple notebook with a simple plot like the one I shared that can be used to replicate this issue

Also can you share screenshots of the error messages, it’s difficult to tell what the problem is without those details

@xiezhipeng-git
Copy link

xiezhipeng-git commented Jul 30, 2024

import matplotlib.pyplot as plt
from IPython.display import clear_output
for i in range(6000):
    #question 1 wsl path windows vscode project only print no clear_output and plt show Kernel crash
    print(i)
    clear_output(wait=True)
    # or try false
    #clear_output(wait=False)
    plt.figure()
    plt.plot([1,2], [1,2])
    plt.show()

@DonJayamanne
Now I can not run in wsl.because my wsl is broken.
but these code could cause vscode to crash or jupter Kernel crash in only windows project. You can try in wsl file path windows vscode project and wsl path wsl vscode project.

@xiezhipeng-git
Copy link

image
Visual Studio Code (1.91.1, undefined, desktop)
Jupyter Extension Version: 2024.6.0.
Python Extension Version: 2024.11.2024072502.
Pylance Extension Version: 2024.7.1.
Platform: win32 (x64).
Workspace folder d:\my\work\rlFrame\rl_frame, Home = c:\Users\Admin
16:37:43.266 [info] Starting Kernel (Python Path: d:\my\env\python3.10.10\python.exe, Unknown, 3.10.10) for 'd:\my\work\test\python_test\plt_test.ipynb' (disableUI=true)
16:37:43.400 [warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 134ms
16:37:43.409 [info] Process Execution: d:\my\env\python3.10.10\python.exe -c "import site;print("USER_BASE_VALUE");print(site.USER_SITE);print("USER_BASE_VALUE");"
16:37:43.418 [warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 136ms
16:37:43.476 [info] Process Execution: d:\my\env\python3.10.10\python.exe -m pip list
16:37:43.480 [info] Process Execution: d:\my\env\python3.10.10\python.exe -c "import ipykernel; print(ipykernel.version); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.file)"
16:37:43.485 [info] Process Execution: d:\my\env\python3.10.10\python.exe c:\Users~.vscode\extensions\ms-toolsai.jupyter-2024.6.0-win32-x64\pythonFiles\vscode_datascience_helpers\kernel_interrupt_daemon.py --ppid 20492
> cwd: ~.vscode\extensions\ms-toolsai.jupyter-2024.6.0-win32-x64\pythonFiles\vscode_datascience_helpers
16:37:43.633 [info] Process Execution: d:\my\env\python3.10.10\python.exe -m ipykernel_launcher --f=c:\Users~\AppData\Roaming\jupyter\runtime\kernel-v2-20492kq870CXwlSjB.json
> cwd: d:\my\work\test\python_test
16:37:44.810 [info] Kernel successfully started
16:37:44.817 [warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 5ms
16:37:44.821 [info] Process Execution: d:\my\env\python3.10.10\python.exe c:\Users~.vscode\extensions\ms-toolsai.jupyter-2024.6.0-win32-x64\pythonFiles\printJupyterDataDir.py
16:48:36.766 [error] Disposing session as kernel process died ExitCode: 3221225477, Reason:

@DonJayamanne
Copy link
Contributor

Can you try laucnhing Jupyter Lab inside the same WSL enviorhnment from the same Python env d:\my\env\python3.10.10\python.exe
Run the same code there as well, and see what happens
When launching Jupyter Lab in WSL, plese ensure to pass --debug argument so we can see whats going on,
This way when it crashes in JupyterLab as well, we'll have the logs in the terminal.

@DonJayamanne DonJayamanne added notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) notebook-output labels Aug 1, 2024
@DonJayamanne
Copy link
Contributor

I've tried this at my end , and it works as expected, took a while to run the cell, but it ran completely without any errors.

@xiezhipeng-git
Copy link

xiezhipeng-git commented Aug 2, 2024

@DonJayamanne
Can't we see the problem through the Windows logs I provided?
I cannot use WSL now because it is damaged and I don't know when it will be restored.
Because I have this issue with both Windows and WSL. Can you provide me with a complete command that can be implemented through Windows

Today, I discovered that the Juypter plugin has automatically updated
And now I can't reproduce the problem on Windows either. WSL is currently unclear

Try opening the file project using Windows VSCode in the WSL path. Then only print. Not cleared. Can you reproduce the path error issue?

@xiezhipeng-git
Copy link

xiezhipeng-git commented Aug 2, 2024

@DonJayamanne
After trying again, it was reproduced.

import matplotlib.pyplot as plt
from IPython.display import clear_output
for i in range(6000):
    clear_output(wait=True)
    plt.figure()
    plt.plot([1,2], [1,2])
    plt.show()
    
    
    print(i)

image

Visual Studio Code (1.92.0, undefined, desktop)
Jupyter Extension Version: 2024.7.0.
Python Extension Version: 2024.13.2024080201.
Pylance Extension Version: 2024.7.1.
Platform: win32 (x64).
Workspace folder d:\my\work\test\python_test, Home = c:\Users\Admin
21:55:12.992 [debug] Start refreshing Kernel Picker (1722606912992)
21:55:13.034 [trace] No controller, hence notebook communications cannot be initialized for editor d:\my\work\test\python_test\input_test.ipynb
21:55:13.037 [debug] Start refreshing Interpreter Kernel Picker
21:55:13.152 [trace] Search for KernelSpecs in Interpreter d:\my\env\python3.10.10\python.exe
21:55:13.153 [trace] Search for KernelSpecs in Interpreter d:\my\env\python3.12.4\python.exe
21:55:13.159 [debug] Get Custom Env Variables, Class name = Sm, completed in 167ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunPythonCode"
21:55:13.159 [debug] Jupyter Paths kernels: 
21:55:13.159 [debug] Kernel Spec Root Paths, ~\AppData\Roaming\jupyter\kernels, c:\ProgramData\jupyter\kernels
21:55:13.279 [debug] KernelProvider switched kernel to id = .jvsc74a57bd0d9556678d02f556b8171da6f4234414674566ea60e98b9cfd43bc7620eeeef71.d:\my\env\python3.10.10\python.exe.d:\my\env\python3.10.10\python.exe.-m#ipykernel_launcher
21:55:13.279 [debug] start the kernel, options.disableUI=true for d:\my\work\test\python_test\input_test.ipynb
21:55:13.284 [trace] Registering commtarget jupyter.widget
21:55:13.285 [debug] Controller selection change completed
21:55:13.336 [debug] Get Custom Env Variables, Class name = Sm, completed in 0ms, has a truthy return value, Arg 1: "/D:/my/work/test/python_test", Arg 2: "RunPythonCode"
21:55:13.336 [info] Starting Kernel (Python Path: d:\my\env\python3.10.10\python.exe, Unknown, 3.10.10) for 'd:\my\work\test\python_test\input_test.ipynb' (disableUI=true)
21:55:13.336 [trace] Creating raw notebook for resource 'd:\my\work\test\python_test\input_test.ipynb'
21:55:13.346 [debug] Get Custom Env Variables, Class name = Sm, completed in 0ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/input_test.ipynb", Arg 2: "RunPythonCode"
21:55:13.409 [trace] Hiding default KernelSpec python for interpreter d:\my\env\python3.10.10\python.exe (KernelSpec file d:\my\env\python3.10.10\share\jupyter\kernels\python3\kernel.json)
21:55:13.460 [debug] Launching kernel .jvsc74a57bd0d9556678d02f556b8171da6f4234414674566ea60e98b9cfd43bc7620eeeef71.d:\my\env\python3.10.10\python.exe.d:\my\env\python3.10.10\python.exe.-m#ipykernel_launcher for d:\my\work\test\python_test\input_test.ipynb in d:\my\work\test\python_test with ports 9001, 9000, 9004, 9002, 9003
21:55:13.471 [warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 135ms
21:55:13.471 [debug] Create ProcessService, Class name = Im (started execution), Arg 1: undefined
21:55:13.472 [warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 126ms
21:55:13.473 [debug] Get Custom Env Variables, Class name = Sm, completed in 2ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunNonPythonCode", Arg 3: undefined
21:55:13.473 [debug] Create ProcessService, Class name = Im, completed in 2ms, has a truthy return value, Arg 1: undefined
21:55:13.477 [info] Process Execution: d:\my\env\python3.10.10\python.exe -c "import site;print("USER_BASE_VALUE");print(site.USER_SITE);print("USER_BASE_VALUE");"
21:55:13.501 [trace] Conda file is conda
21:55:13.536 [trace] USER_SITE for d:\my\env\python3.10.10\python.exe is c:\Users\~\AppData\Roaming\Python\Python310\Scripts
21:55:13.537 [trace] Prepend PATH with user site path for d:\my\env\python3.10.10\python.exe, user site c:\Users\~\AppData\Roaming\Python\Python310\Scripts
21:55:13.537 [trace] Prepend PATH with python bin for d:\my\env\python3.10.10\python.exe
21:55:13.537 [trace] Prepend PATH with user site path for d:\my\env\python3.10.10\python.exe, user site c:\Users\~\AppData\Roaming\Python\Python310\Scripts
21:55:13.537 [trace] Prepend PATH with python bin for d:\my\env\python3.10.10\python.exe
21:55:13.537 [debug] Getting activated env variables, Class name = pd, completed in 201ms, has a truthy return value, Arg 1: "/D:/my/work/test/python_test", Arg 2: "D:\\MY\\ENV\\PYTHON3.10.10\\PYTHON.EXE", Arg 3: undefined
21:55:13.537 [debug] Getting activated env variables, Class name = pd, completed in 191ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/input_test.ipynb", Arg 2: "D:\\MY\\ENV\\PYTHON3.10.10\\PYTHON.EXE", Arg 3: undefined
21:55:13.540 [info] Process Execution: d:\my\env\python3.10.10\python.exe -m pip list
21:55:13.544 [info] Process Execution: d:\my\env\python3.10.10\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
21:55:13.548 [info] Process Execution: d:\my\env\python3.10.10\python.exe c:\Users\~\.vscode\extensions\ms-toolsai.jupyter-2024.7.0-win32-x64\pythonFiles\vscode_datascience_helpers\kernel_interrupt_daemon.py --ppid 7824
    > cwd: ~\.vscode\extensions\ms-toolsai.jupyter-2024.7.0-win32-x64\pythonFiles\vscode_datascience_helpers
21:55:13.550 [trace] Python API env change detected, update => 'D:\MY\ENV\PYTHON3.10.10\PYTHON.EXE'
21:55:13.551 [trace] Python API env change detected, update => 'D:\MY\ENV\PYTHON3.12.4\PYTHON.EXE'
21:55:13.551 [debug] Refreshed Environments
21:55:13.699 [trace] Got a response of 1428 for INITIALIZE_INTERRUPT:0
21:55:13.704 [info] Process Execution: d:\my\env\python3.10.10\python.exe -m ipykernel_launcher --f=c:\Users\~\AppData\Roaming\jupyter\runtime\kernel-v2-78248cGgTgXOPP8c.json
    > cwd: d:\my\work\test\python_test
21:55:13.704 [debug] Kernel process 5088.
21:55:13.834 [trace] ipykernel version & path 6.29.4, d:\my\env\python3.10.10\lib\site-packages\ipykernel\__init__.py for d:\my\env\python3.10.10\python.exe
21:55:14.227 [debug] Interpreter for Pylance for Notebook URI "d:\my\work\test\python_test\input_test.ipynb" is d:\my\env\python3.10.10\python.exe
21:55:14.550 [debug] Waiting for Raw Session to be ready in postStartRawSession
21:55:14.550 [debug] Waiting for Raw session to be ready, status: connected
21:55:14.550 [trace] Raw session connected
21:55:14.550 [debug] Waited for Raw session to be ready & got status: connected
21:55:14.550 [debug] Successfully waited for Raw Session to be ready in postStartRawSession
21:55:14.550 [debug] Kernel status is 'unknown' before requesting kernel info and after ready
21:55:14.550 [debug] Sending request for kernelInfo
21:55:14.551 [debug] Kernel output 5088: To connect another client to this kernel, use:
--existing c:\Users\~\AppData\Roaming\jupyter\runtime\kernel-v2-78248cGgTgXOPP8c.json
21:55:14.551 [debug] End refreshing Kernel Picker (1722606912992)
21:55:14.749 [trace] Got response for requestKernelInfo
21:55:14.749 [debug] Successfully completed postStartRawSession after 1 attempt(s) in 199ms
21:55:14.749 [trace] Executing silently Code (idle) = import sys as _VSCODE_sys\nprint(_VSCODE_sys.executable); del _VSCODE_sys
21:55:14.771 [trace] Executing silently Code (completed) = import sys as _VSCODE_sys\nprint(_VSCODE_sys.executable); del _VSCODE_sys with 1 output(s)
21:55:14.771 [trace] Started running kernel initialization for d:\my\work\test\python_test\input_test.ipynb
21:55:14.772 [trace] Executing silently Code (idle) = try:\nimport ipywidgets as _VSCODE_ipywidgets\nprint("e976ee50-99ed-4aba-9b6b-9dcd5634d07d:IPy
21:55:14.852 [trace] Executing silently Code (completed) = try:\nimport ipywidgets as _VSCODE_ipywidgets\nprint("e976ee50-99ed-4aba-9b6b-9dcd5634d07d:IPy with 1 output(s)
21:55:14.853 [trace] Determined IPyWidgets Version as 8
21:55:14.853 [trace] Version of IPyWidgets 8 determined after 1.568s
21:55:14.854 [trace] Executing silently Code (idle) = def __VSCODE_inject_module():\ndef __VSCODE_call_function(function, callback, data=None):
21:55:14.866 [trace] Executing silently Code (completed) = def __VSCODE_inject_module():\ndef __VSCODE_call_function(function, callback, data=None): with 0 output(s)
21:55:14.866 [debug] Requesting Kernel info
21:55:14.867 [trace] Got Kernel info
21:55:14.867 [trace] End running kernel initialization, now waiting for idle
21:55:14.867 [trace] Waiting for idle on (kernel): 21f3ffe2-aea7-43ae-9319-2d68a5995a9f -> idle
21:55:14.867 [trace] Finished waiting for idle on (kernel): 21f3ffe2-aea7-43ae-9319-2d68a5995a9f -> idle
21:55:14.867 [trace] End running kernel initialization, session is idle
21:55:14.867 [trace] Registering Kernel Completion Provider from kernel Python 3.10.10 for language python
21:55:14.868 [trace] IPyWidgetScriptSource.initialize
21:55:14.868 [info] Kernel successfully started
21:55:14.869 [debug] getDataDirsImpl, Class name = Mr (started execution), Arg 1: "/d:/my/work/test/python_test/input_test.ipynb", Arg 2: "D:\\MY\\ENV\\PYTHON3.10.10\\PYTHON.EXE"
21:55:14.869 [debug] Get Custom Env Variables, Class name = Sm, completed in 0ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunPythonCode"
21:55:14.869 [debug] Jupyter Paths : 
21:55:14.869 [debug] Get Custom Env Variables, Class name = Sm, completed in 0ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/input_test.ipynb", Arg 2: "RunPythonCode"
21:55:14.878 [warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 9ms
21:55:14.879 [trace] Prepend PATH with user site path for d:\my\env\python3.10.10\python.exe, user site c:\Users\~\AppData\Roaming\Python\Python310\Scripts
21:55:14.879 [trace] Prepend PATH with python bin for d:\my\env\python3.10.10\python.exe
21:55:14.880 [debug] Getting activated env variables, Class name = pd, completed in 11ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/input_test.ipynb", Arg 2: "D:\\MY\\ENV\\PYTHON3.10.10\\PYTHON.EXE", Arg 3: undefined
21:55:14.885 [info] Process Execution: d:\my\env\python3.10.10\python.exe c:\Users\~\.vscode\extensions\ms-toolsai.jupyter-2024.7.0-win32-x64\pythonFiles\printJupyterDataDir.py
21:55:14.953 [debug] getDataDirsImpl, Class name = Mr, completed in 84ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/input_test.ipynb", Arg 2: "D:\\MY\\ENV\\PYTHON3.10.10\\PYTHON.EXE", Return Value: <Uri:/C:/Users/~/AppData/Roaming/Python/share/jupyter>, <Uri:/C:/Users/~/AppData/Roaming/jupyter>, <Uri:/D:/my/env/python3.10.10/share/jupyter>, <Uri:/C:/ProgramData/jupyter>
21:55:15.374 [trace] Web view is ready to receive widget messages
21:55:15.376 [trace] Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
21:55:15.377 [trace] Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
21:55:15.381 [trace] Widget Message: data-base-url set to https://file%2B.vscode-resource.vscode-cdn.net/c%3A/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.7.0-win32-x64/temp/scripts/c1448ee990f1e2327aee6423b60d380730cb6f96db29818006120e19dc2233aa/jupyter
21:55:15.381 [trace] Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
21:55:15.381 [trace] Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
21:55:15.382 [trace] Widget Message: data-base-url set to https://file%2B.vscode-resource.vscode-cdn.net/c%3A/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.7.0-win32-x64/temp/scripts/c1448ee990f1e2327aee6423b60d380730cb6f96db29818006120e19dc2233aa/jupyter
21:55:23.051 [debug] Handle Execution of Cells 0 for d:\my\work\test\python_test\input_test.ipynb
21:55:23.053 [trace] Cell Index:0 sent to kernel
21:55:23.056 [trace] Start cell 0 execution @ 1722606923056 (clear output)
21:55:23.057 [debug] Kernel acknowledged execution of cell 0 @ 1722606923056
21:55:23.068 [trace] Cell 0 completed in 0.012s (start: 1722606923056, end: 1722606923068)
21:55:23.068 [trace] Cell 0 executed successfully
21:55:27.156 [debug] Handle Execution of Cells 1 for d:\my\work\test\python_test\input_test.ipynb
21:55:27.157 [trace] Cell Index:1 sent to kernel
21:55:27.159 [trace] Start cell 1 execution @ 1722606927159 (clear output)
21:55:27.159 [debug] Kernel acknowledged execution of cell 1 @ 1722606927159
21:55:39.954 [trace] Cell 1 completed in 12.795s (start: 1722606927159, end: 1722606939954)
21:55:39.955 [trace] Cell 1 executed successfully
21:55:49.113 [trace] Executing silently Code (idle) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info
21:55:49.114 [trace] Executing silently Code (idle) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info
21:55:49.151 [trace] Executing silently Code (completed) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info with 1 output(s)
21:55:49.183 [trace] Executing silently Code (completed) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info with 1 output(s)
21:57:27.162 [trace] No controller, hence notebook communications cannot be initialized for editor d:\my\work\test\python_test\plt_test.ipynb
21:57:27.163 [debug] No interpreter for Pylance for Notebook URI "d:\my\work\test\python_test\plt_test.ipynb"
21:57:31.877 [debug] KernelProvider switched kernel to id = .jvsc74a57bd0d9556678d02f556b8171da6f4234414674566ea60e98b9cfd43bc7620eeeef71.d:\my\env\python3.10.10\python.exe.d:\my\env\python3.10.10\python.exe.-m#ipykernel_launcher
21:57:31.877 [debug] start the kernel, options.disableUI=true for d:\my\work\test\python_test\plt_test.ipynb
21:57:31.878 [trace] Registering commtarget jupyter.widget
21:57:31.878 [debug] Controller selection change completed
21:57:31.879 [info] Starting Kernel (Python Path: d:\my\env\python3.10.10\python.exe, Unknown, 3.10.10) for 'd:\my\work\test\python_test\plt_test.ipynb' (disableUI=true)
21:57:31.879 [trace] Creating raw notebook for resource 'd:\my\work\test\python_test\plt_test.ipynb'
21:57:31.880 [debug] Get Custom Env Variables, Class name = Sm, completed in 0ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/plt_test.ipynb", Arg 2: "RunPythonCode"
21:57:31.933 [debug] Launching kernel .jvsc74a57bd0d9556678d02f556b8171da6f4234414674566ea60e98b9cfd43bc7620eeeef71.d:\my\env\python3.10.10\python.exe.d:\my\env\python3.10.10\python.exe.-m#ipykernel_launcher for d:\my\work\test\python_test\plt_test.ipynb in d:\my\work\test\python_test with ports 9006, 9005, 9009, 9007, 9008
21:57:31.934 [trace] Got a response of 1980 for INITIALIZE_INTERRUPT:1
21:57:31.935 [warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 55ms
21:57:31.936 [trace] Prepend PATH with user site path for d:\my\env\python3.10.10\python.exe, user site c:\Users\~\AppData\Roaming\Python\Python310\Scripts
21:57:31.936 [trace] Prepend PATH with python bin for d:\my\env\python3.10.10\python.exe
21:57:31.936 [debug] Getting activated env variables, Class name = pd, completed in 56ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/plt_test.ipynb", Arg 2: "D:\\MY\\ENV\\PYTHON3.10.10\\PYTHON.EXE", Arg 3: undefined
21:57:31.938 [info] Process Execution: d:\my\env\python3.10.10\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
21:57:31.942 [info] Process Execution: d:\my\env\python3.10.10\python.exe -m ipykernel_launcher --f=c:\Users\~\AppData\Roaming\jupyter\runtime\kernel-v2-78245W6lh1WzVDdw.json
    > cwd: d:\my\work\test\python_test
21:57:31.942 [debug] Kernel process 16760.
21:57:32.195 [trace] ipykernel version & path 6.29.4, d:\my\env\python3.10.10\lib\site-packages\ipykernel\__init__.py for d:\my\env\python3.10.10\python.exe
21:57:32.728 [debug] Kernel output 16760: To connect another client to this kernel, use:
--existing c:\Users\~\AppData\Roaming\jupyter\runtime\kernel-v2-78245W6lh1WzVDdw.json
21:57:32.777 [debug] Waiting for Raw Session to be ready in postStartRawSession
21:57:32.777 [debug] Waiting for Raw session to be ready, status: connected
21:57:32.777 [trace] Raw session connected
21:57:32.777 [debug] Waited for Raw session to be ready & got status: connected
21:57:32.777 [debug] Successfully waited for Raw Session to be ready in postStartRawSession
21:57:32.777 [debug] Kernel status is 'unknown' before requesting kernel info and after ready
21:57:32.777 [debug] Sending request for kernelInfo
21:57:32.869 [trace] Got response for requestKernelInfo
21:57:32.869 [debug] Successfully completed postStartRawSession after 1 attempt(s) in 92ms
21:57:32.870 [trace] Executing silently Code (busy) = import sys as _VSCODE_sys\nprint(_VSCODE_sys.executable); del _VSCODE_sys
21:57:32.912 [trace] Executing silently Code (completed) = import sys as _VSCODE_sys\nprint(_VSCODE_sys.executable); del _VSCODE_sys with 1 output(s)
21:57:32.912 [trace] Started running kernel initialization for d:\my\work\test\python_test\plt_test.ipynb
21:57:32.912 [trace] Executing silently Code (idle) = try:\nimport ipywidgets as _VSCODE_ipywidgets\nprint("e976ee50-99ed-4aba-9b6b-9dcd5634d07d:IPy
21:57:32.975 [trace] Executing silently Code (completed) = try:\nimport ipywidgets as _VSCODE_ipywidgets\nprint("e976ee50-99ed-4aba-9b6b-9dcd5634d07d:IPy with 1 output(s)
21:57:32.975 [trace] Determined IPyWidgets Version as 8
21:57:32.975 [trace] Version of IPyWidgets 8 determined after 1.097s
21:57:32.976 [trace] Executing silently Code (idle) = def __VSCODE_inject_module():\ndef __VSCODE_call_function(function, callback, data=None):
21:57:32.991 [trace] Executing silently Code (completed) = def __VSCODE_inject_module():\ndef __VSCODE_call_function(function, callback, data=None): with 0 output(s)
21:57:32.992 [debug] Requesting Kernel info
21:57:32.992 [trace] Got Kernel info
21:57:32.993 [trace] End running kernel initialization, now waiting for idle
21:57:32.993 [trace] Waiting for idle on (kernel): 60963a42-d60d-469d-b3fe-768005fb8081 -> idle
21:57:32.993 [trace] Finished waiting for idle on (kernel): 60963a42-d60d-469d-b3fe-768005fb8081 -> idle
21:57:32.994 [trace] End running kernel initialization, session is idle
21:57:32.994 [trace] Registering Kernel Completion Provider from kernel Python 3.10.10 for language python
21:57:32.994 [trace] IPyWidgetScriptSource.initialize
21:57:32.994 [info] Kernel successfully started
21:57:33.500 [trace] Web view is ready to receive widget messages
21:57:33.502 [trace] Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
21:57:33.503 [trace] Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
21:57:33.504 [trace] Widget Message: data-base-url set to https://file%2B.vscode-resource.vscode-cdn.net/c%3A/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.7.0-win32-x64/temp/scripts/c1448ee990f1e2327aee6423b60d380730cb6f96db29818006120e19dc2233aa/jupyter
21:57:33.505 [trace] Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
21:57:33.505 [trace] Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
21:57:33.506 [trace] Widget Message: data-base-url set to https://file%2B.vscode-resource.vscode-cdn.net/c%3A/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.7.0-win32-x64/temp/scripts/c1448ee990f1e2327aee6423b60d380730cb6f96db29818006120e19dc2233aa/jupyter
21:57:40.244 [debug] Handle Execution of Cells 0 for d:\my\work\test\python_test\plt_test.ipynb
21:57:40.245 [trace] Cell Index:0 sent to kernel
21:57:40.247 [trace] Start cell 0 execution @ 1722607060247 (clear output)
21:57:40.247 [debug] Kernel acknowledged execution of cell 0 @ 1722607060247
22:02:53.822 [trace] Cell 0 completed in 313.575s (start: 1722607060247, end: 1722607373822)
22:02:53.823 [trace] Cell 0 executed successfully
22:02:53.858 [debug] Jupyter completion time: 68237
22:02:53.870 [debug] Execution of code ms-toolsai.jupyter-1 completed in 68248ms
22:03:13.854 [debug] Restart kernel command handler for d:\my\work\test\python_test\plt_test.ipynb
22:03:14.829 [debug] restart the kernel, options.disableUI=false for d:\my\work\test\python_test\plt_test.ipynb
22:03:14.829 [info] Restart requested d:\my\work\test\python_test\plt_test.ipynb
22:03:14.830 [debug] Cancel pending cells
22:03:14.830 [debug] Dispose Kernel process 16760.
22:03:14.833 [info] Process Execution: c:\windows\System32\taskkill.exe /F /T /PID 16760
22:03:14.834 [debug] Get Custom Env Variables, Class name = Sm, completed in 0ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/plt_test.ipynb", Arg 2: "RunPythonCode"
22:03:14.889 [debug] Launching kernel .jvsc74a57bd0d9556678d02f556b8171da6f4234414674566ea60e98b9cfd43bc7620eeeef71.d:\my\env\python3.10.10\python.exe.d:\my\env\python3.10.10\python.exe.-m#ipykernel_launcher for d:\my\work\test\python_test\plt_test.ipynb in d:\my\work\test\python_test with ports 9011, 9010, 9014, 9012, 9013
22:03:14.890 [trace] Got a response of 2844 for INITIALIZE_INTERRUPT:2
22:03:14.892 [warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 58ms
22:03:14.892 [trace] Prepend PATH with user site path for d:\my\env\python3.10.10\python.exe, user site c:\Users\~\AppData\Roaming\Python\Python310\Scripts
22:03:14.893 [trace] Prepend PATH with python bin for d:\my\env\python3.10.10\python.exe
22:03:14.893 [debug] Getting activated env variables, Class name = pd, completed in 59ms, has a truthy return value, Arg 1: "/d:/my/work/test/python_test/plt_test.ipynb", Arg 2: "D:\\MY\\ENV\\PYTHON3.10.10\\PYTHON.EXE", Arg 3: undefined
22:03:14.896 [info] Process Execution: d:\my\env\python3.10.10\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
22:03:14.903 [info] Process Execution: d:\my\env\python3.10.10\python.exe -m ipykernel_launcher --f=c:\Users\~\AppData\Roaming\jupyter\runtime\kernel-v2-7824tbvUAWtT200y.json
    > cwd: d:\my\work\test\python_test
22:03:14.903 [debug] Kernel process 8436.
22:03:14.923 [debug] Disposed Kernel process 16760.
22:03:14.928 [debug] KernelProcess Exited 16760, Exit Code - 1
22:03:15.159 [trace] ipykernel version & path 6.29.4, d:\my\env\python3.10.10\lib\site-packages\ipykernel\__init__.py for d:\my\env\python3.10.10\python.exe
22:03:15.634 [debug] Kernel output 8436: To connect another client to this kernel, use:
--existing c:\Users\~\AppData\Roaming\jupyter\runtime\kernel-v2-7824tbvUAWtT200y.json
22:03:15.726 [debug] Waiting for Raw Session to be ready in postStartRawSession
22:03:15.726 [debug] Waiting for Raw session to be ready, status: connected
22:03:15.726 [trace] Raw session connected
22:03:15.726 [debug] Waited for Raw session to be ready & got status: connected
22:03:15.726 [debug] Successfully waited for Raw Session to be ready in postStartRawSession
22:03:15.726 [debug] Kernel status is 'unknown' before requesting kernel info and after ready
22:03:15.726 [debug] Sending request for kernelInfo
22:03:15.795 [trace] Got response for requestKernelInfo
22:03:15.795 [debug] Successfully completed postStartRawSession after 1 attempt(s) in 69ms
22:03:15.796 [info] Restarted 60963a42-d60d-469d-b3fe-768005fb8081
22:03:15.796 [trace] Executing silently Code (idle) = import sys as _VSCODE_sys\nprint(_VSCODE_sys.executable); del _VSCODE_sys
22:03:15.798 [trace] Widget Message: Received IPyWidgetMessages.IPyWidgets_onRestartKernel
22:03:15.807 [trace] Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
22:03:15.810 [trace] Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
22:03:15.815 [trace] Executing silently Code (completed) = import sys as _VSCODE_sys\nprint(_VSCODE_sys.executable); del _VSCODE_sys with 1 output(s)
22:03:15.815 [trace] Started running kernel initialization for d:\my\work\test\python_test\plt_test.ipynb
22:03:15.816 [trace] Executing silently Code (idle) = try:\nimport ipywidgets as _VSCODE_ipywidgets\nprint("e976ee50-99ed-4aba-9b6b-9dcd5634d07d:IPy
22:03:15.879 [trace] Executing silently Code (completed) = try:\nimport ipywidgets as _VSCODE_ipywidgets\nprint("e976ee50-99ed-4aba-9b6b-9dcd5634d07d:IPy with 1 output(s)
22:03:15.879 [trace] Determined IPyWidgets Version as 8
22:03:15.880 [trace] Executing silently Code (idle) = def __VSCODE_inject_module():\ndef __VSCODE_call_function(function, callback, data=None):
22:03:15.895 [trace] Executing silently Code (completed) = def __VSCODE_inject_module():\ndef __VSCODE_call_function(function, callback, data=None): with 0 output(s)
22:03:15.895 [debug] Requesting Kernel info
22:03:15.896 [trace] Got Kernel info
22:03:15.896 [trace] End running kernel initialization, now waiting for idle
22:03:15.896 [trace] Waiting for idle on (kernel): 60963a42-d60d-469d-b3fe-768005fb8081 -> idle
22:03:15.896 [trace] Finished waiting for idle on (kernel): 60963a42-d60d-469d-b3fe-768005fb8081 -> idle
22:03:15.897 [trace] End running kernel initialization, session is idle
22:03:15.898 [trace] Registering commtarget jupyter.widget
22:03:19.086 [debug] Handle Execution of Cells 0,1 for d:\my\work\test\python_test\plt_test.ipynb
22:03:19.087 [trace] Cell Index:0 sent to kernel
22:03:19.090 [trace] Start cell 0 execution @ 1722607399090 (clear output)
22:03:19.090 [debug] Kernel acknowledged execution of cell 0 @ 1722607399090
22:08:34.852 [trace] Cell 0 completed in 315.762s (start: 1722607399090, end: 1722607714852)
22:08:34.853 [trace] Cell 0 executed successfully
22:08:34.854 [trace] Cell Index:1 sent to kernel
22:08:34.857 [trace] Start cell 1 execution @ 1722607714857 (clear output)
22:08:34.857 [debug] Kernel acknowledged execution of cell 1 @ 1722607714857
22:08:34.868 [trace] Cell 1 completed in 0.011s (start: 1722607714857, end: 1722607714868)
22:08:34.868 [trace] Cell 1 executed successfully
22:09:10.816 [debug] Handle Execution of Cells 0 for d:\my\work\test\python_test\plt_test.ipynb
22:09:10.816 [trace] Cell Index:0 sent to kernel
22:09:10.819 [trace] Start cell 0 execution @ 1722607750819 (clear output)
22:09:10.819 [debug] Kernel acknowledged execution of cell 0 @ 1722607750819
22:12:19.085 [debug] KernelProcess Exited 8436, Exit Code - 3221225477 
22:12:19.086 [error] Disposing session as kernel process died ExitCode: 3221225477, Reason: 
22:12:19.086 [debug] Dispose Kernel process 8436.
22:12:19.088 [debug] Disposed Kernel process 8436.
22:12:19.103 [trace] Cell 0 completed in -1722607750.819s (start: 1722607750819, end: undefined)

@DonJayamanne
Copy link
Contributor

Please can you try using Jupyter lab and get logs from there when you repro it

Instructions here

#15834 (comment)

@xiezhipeng-git
Copy link

xiezhipeng-git commented Aug 4, 2024

@DonJayamanne
How does switch to Jupyter lab? And, although I get the same error as @https://github.com/aldojacopovirno. But it's not necessarily the same error, yet the link you gave for the introduction is just the current page.Are you sure you didn't give the wrong one?

@DonJayamanne
Copy link
Contributor

The link was correct, basically please use Jupyter lab from the same environment
‘d:\my\env\python3.10.10\python.exe -m pip install jupyterlab’
Then run Jupyter from that same environment
‘ d:\my\env\python3.10.10\python.exe -m Jupyter lab’

Note, please ensure you have activated the python env as well

warn] Failed to get activated env vars for d:\my\env\python3.10.10\python.exe in 58ms

Btw, what kind of environment is this? Conda or virtual environment or other?

@xiezhipeng-git
Copy link

xiezhipeng-git commented Aug 5, 2024

@DonJayamanne
The term 'jupyter' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
only
PS D:\my\work\test\python_test> jupyter-lab --version
4.2.1
windows,vscode,Nomal python. No use virtual environment
If use jupyter-lab
There is no Kernel crash problem.
So the problem is from vscode or ipykernel?

@DonJayamanne
Copy link
Contributor

Please install Jupyter into the same Python environment using the following script

‘d:\my\env\python3.10.10\python.exe -m pip install jupyterlab’

@xiezhipeng-git
Copy link

@DonJayamanne
Your local version is outdated.
The new version seems to be like this here.
There is only a unified Jupyter-feature name. Similar commands like this
image

@DonJayamanne
Copy link
Contributor

Can you share a screenshot of the output from the terminal when you run here above command

@xiezhipeng-git
Copy link

xiezhipeng-git commented Aug 5, 2024

Is it Jupyter-lab?
image
There is no crash if use Jupyter-lab
The crash state only in vscode

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Aug 5, 2024

Please can you confirm you ran this command

‘d:\my\env\python3.10.10\python.exe -m pip install jupyterlab’

I’m sorry, but can you try the above first,
We need to ensure Jupyter lab is installed in the same Python environment

@xiezhipeng-git
Copy link

xiezhipeng-git commented Aug 5, 2024

Please can you confirm you ran this command

‘d:\my\env\python3.10.10\python.exe -m pip install jupyterlab’

I’m sorry, but can you try the above first, We need to ensure Jupyter lab is installed in the same Python environment

use d:\my\env\python3.10.10\python.exe -m pip install jupyterlab
and
jupyter-lab
It is crashed
image

@DonJayamanne
Copy link
Contributor

Than you for getting back with that information

This proves that the problem is not with vscode
The kernel is crashing in Jupyter lab as well, as it’s not related to vscode I’m closing this issue

I would suggest recreating the python environment, or using another environment and reinstalling the packages

@xiezhipeng-git
Copy link

xiezhipeng-git commented Aug 5, 2024

@DonJayamanne
So where should this issue be fed back to? PLT or Jupyter

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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) notebook-output
Projects
None yet
Development

No branches or pull requests

3 participants