
Jupyter Notebook - our main star for this blog post.Visual Studio Code - its free, its great, its awesome.So before we go ahead and start F10-ing our code, some prerequisites:

Simple print is all we need, but as you dive deeper into the world of creating complex programs using the notebook, you need more than print.įortunately, Visual Studio Code has a nice way to do it. Most common reply I got was, “well, if your stuck with Jupyter, just use print”. So when I began using Jupyter Notebook, one of my first question was - How do I step trough the code and debug this thing?.

In my daily grind, most of my time is doing F10’s to a code and watch variables change value - the sad story of a software maintenance guy using Visual Studio. You can then upload the notebook to your normal Jupyter environment.How To Debug Jupyter Notebooks in Visual Studio Code ĭebugging your code is a common activity for developers. Save the file, then export the notebook as described in the following section. When you're satisfied that all your code is correct. To familiarize yourself with the general debugging features of VS Code, such as inspecting variables, setting breakpoints, and other activities, review VS Code debugging.Īs you find issues, stop the debugger, correct your code, save the file, and run the debugger again. ipynb file, of course, and setting a breakpoint in an appropriate location in your notebook code. (Download the file first if you're using a cloud-based Jupyter environment such as Azure Notebooks.)įollow the instructions to configure and run the debugger as described on Tutorial - Configure and run the debugger, using your imported. ipynb file into VS Code as described in the previous section. In VS Code, activate a Python environment in which Jupyter is installed, as described at the beginning of this article. Using the debugger is a helpful way to find and correct issues in notebook code.

The Visual Studio Code debugger lets you step through your code, set breakpoints, examine state, and analyze problems. (If you start the server in the VS Code terminal with an authentication token enabled, the URL with the token typically appears in the terminal output from where you can copy it.) When prompted, provide the server's URI (hostname) with the authentication token included with a ?token= URL parameter. Run the Python: Specify Jupyter server URI command from the Command Palette ( Ctrl+Shift+P). Once connected, code cells run on the remote server rather than the local computer. You can offload intensive computation in a Jupyter notebook to other computers by connecting to a remote Jupyter server. Python: Select Interpreter command from the Command Palette ( Ctrl+Shift+P ). Working with Jupyter Notebooks in Visual Studio Code
