I’m using Visual Studio Code with Python installed, and I’m encountering an issue where Jupyter notebooks are not running properly.
When I execute a cell in the Jupyter notebook in VS Code, it starts running but never stops or completes. The notebook remains in the “running” state indefinitely, and the code does not execute successfully.
What I’ve Tried:
Running Python scripts in the terminal works perfectly fine.
I’ve installed the Python extension and the Jupyter extension in VS Code.
I have installed Python 3.11.9 and can confirm it works in the terminal.
No errors are shown in the Problems section of VS Code, and there are no obvious issues with the setup.
Environment:
OS:Windows 10
Python Version: 3.11.9
Any suggestions on why the Jupyter notebook is stuck running indefinitely and how I can fix this issue? Thanks in advance!
4
You probably are in the wrong kernel or Python venv.
If you are not sure what is a venv and how to create them, refer to
this documentation.
Make sure to always check here which venv you are in.
It is always recommended to use venv instead of using your Python in PATH.
Examples below show python installations in PATH (DO NOT USE THIS)
Create a new venv in the directory of your project then use that venve to run your notebook. documentation
It should look something like this: (venv)
In the example above, I have a data-proj-venv using Python 3.12.5 which I use when working on data science projects.
Trust me, learn about virtual environments, how they work, and why
they are used. You will save yourself a lot of headaches in the
future.