最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Virtual environment won't start in ipynb in VScode - Stack Overflow

programmeradmin2浏览0评论

I created a few virtual environments for several projects, which all seem to work fine when I run them through the command prompt (by running the python.exe file in the environment), or when I start a Jupyter notebook file whenever I have this evironment activated in the command prompt. Also, I can run regular Python files perfectly fine in VScode. However: running a Python notebook file within VSCode does not seem to work, as I am getting error messages when I try to activate the kernel.

Visual Studio Code (1.98.2, undefined, desktop)
Jupyter Extension Version: 2025.2.0.
Python Extension Version: 2025.2.0.
Pylance Extension Version: 2025.3.2.
Platform: win32 (x64).
Home = c:\Users\NAME_INITIALS
Temp Storage folder ~\AppData\Roaming\Code\User\globalStorage\ms-toolsai.jupyter\version-2025.2.0
Workspace folder ~\OneDrive\Desktop
14:35:34.690 [info] Starting Kernel (Python Path: g:\Environments\test_1234\Scripts\python.exe, Venv, 3.12.7) for '~\OneDrive\Desktop\Untitled-1.ipynb' (disableUI=true)
14:35:55.882 [info] Process Execution: g:\Environments\test_1234\Scripts\python.exe -m pip list
14:35:56.211 [info] Process Execution: g:\Environments\test_1234\Scripts\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
14:36:55.493 [info] Process Execution: ~\Anaconda3\python.exe c:\Users\~\.vscode\extensions\ms-toolsai.jupyter-2025.2.0-win32-x64\pythonFiles\vscode_datascience_helpers\kernel_interrupt_daemon.py --ppid 15820
    > cwd: ~\.vscode\extensions\ms-toolsai.jupyter-2025.2.0-win32-x64\pythonFiles\vscode_datascience_helpers
14:36:55.944 [info] Process Execution: g:\Environments\test_1234\Scripts\python.exe -m ipykernel_launcher --f=c:\Users\~\AppData\Roaming\jupyter\runtime\kernel-v3fb5da8327d726ee0f36face47c345e7a58909d6f.json
    > cwd: ~\OneDrive\Desktop
14:37:55.968 [warn] Waited 60019ms for kernel to start [Error: timeout
    at Timeout.d (c:\Users\~\.vscode\extensions\ms-toolsai.jupyter-2025.2.0-win32-x64\dist\extension.node.js:45:1754)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)]
14:37:55.971 [error] Disposing kernel process due to an error Error: Unable to start Kernel 'test_1234 (Python 3.12.7)' due to a timeout waiting for the ports to get used. 
View Jupyter [log](command:jupyter.viewOutput) for further details.
    > Kernel Id = .jvsc74a57bd0e19f35a6008efc11b6bc4c325f4091a8fd7679a78612207a8b89955fc3d76a7d.g:\Environments\test_1234\Scripts\python.exe.g:\Environments\test_1234\Scripts\python.exe.-m#ipykernel_launcher
    > Interpreter Id = g:\Environments\test_1234\Scripts\python.exe
    > at c:\Users\~\.vscode\extensions\ms-toolsai.jupyter-2025.2.0-win32-x64\dist\extension.node.js:296:46287
14:37:55.971 [error] 
14:37:55.986 [info] Process Execution: c:\WINDOWS\System32\taskkill.exe /F /T /PID 18352
14:37:55.992 [error] Failed to connect raw kernel session: Error: Unable to start Kernel 'test_1234 (Python 3.12.7)' due to a timeout waiting for the ports to get used. 
View Jupyter [log](command:jupyter.viewOutput) for further details.
14:37:55.992 [error] Failed to connect raw kernel session: Error: Unable to start Kernel 'test_1234 (Python 3.12.7)' due to a timeout waiting for the ports to get used. 
View Jupyter [log](command:jupyter.viewOutput) for further details.
14:37:55.996 [warn] Failed to shutdown kernel, .jvsc74a57bd0e19f35a6008efc11b6bc4c325f4091a8fd7679a78612207a8b89955fc3d76a7d.g:\Environments\test_1234\Scripts\python.exe.g:\Environments\test_1234\Scripts\python.exe.-m#ipykernel_launcher [TypeError: Cannot read properties of undefined (reading 'dispose')
    at Z_.shutdown (c:\Users\~\.vscode\extensions\ms-toolsai.jupyter-2025.2.0-win32-x64\dist\extension.node.js:301:13745)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:545:9)
    at process.processTimers (node:internal/timers:519:7)
    at async eT.shutdown (c:\Users\~\.vscode\extensions\ms-toolsai.jupyter-2025.2.0-win32-x64\dist\extension.node.js:301:22578)]
14:37:56.348 [warn] Error occurred while trying to start the kernel, options.disableUI=true Error: Unable to start Kernel 'test_1234 (Python 3.12.7)' due to a timeout waiting for the ports to get used. 
View Jupyter [log](command:jupyter.viewOutput) for further details.
    > Kernel Id = .jvsc74a57bd0e19f35a6008efc11b6bc4c325f4091a8fd7679a78612207a8b89955fc3d76a7d.g:\Environments\test_1234\Scripts\python.exe.g:\Environments\test_1234\Scripts\python.exe.-m#ipykernel_launcher
    > Interpreter Id = g:\Environments\test_1234\Scripts\python.exe
    > at c:\Users\~\.vscode\extensions\ms-toolsai.jupyter-2025.2.0-win32-x64\dist\extension.node.js:296:46287

I already tried reinstalling VScode, and deleting all VSCode related files, settings, and extensions. I also tried creating a new and empty virtual environment, but also when I try to activate that new environment, I keep on running into the error above.

发布评论

评论列表(0)

  1. 暂无评论