Visual Studio Jupyter



Visual Studio 2017 now supports use of a Jupyter Notebook. A Lap Around Python in Visual Studio 2017 According to the MSDN blog post: To work with a notebook, simply download your IPYNB file as a.py file and open it in Visual Studio. JupyterHub lets you create tokens for yourself for use by third party applications. These tokens can be used anywhere a Jupyter Notebook access token is needed. Since this is what Visual Studio Code needs, let’s acquire one. Log-in to your JupyterHub. Use the Azure Machine Learning Visual Studio Code extension to create a new workspace if you don't already have one. To connect to a compute instance: Open a Jupyter Notebook in Visual Studio Code. When the integrated notebook experience loads, select Jupyter Server.

Standard settings

Visual Studio Code Jupyter Server Not Started

Default kernel

If you have more than one kernel you could optionally configure the default kernel either at a user level of workspace (project) level.If configuring at a user level then edit the user settings file else edit the workspace settings file.Add or change the following setting to setup the default kernel:

Startup code

Vscode Debug Jupyter

Vscode debug jupyterJupyterStudio

When using libraries such as matplotlib, the default behaviour of jupyter is to display an interactive graph that is (quite unfortunately - for now) supported only in the Jupyter Notebook.Note: This will change in a future release of this extension along with a future release of matplotlib.Such interactive graphs are only understood by the Jupyter Notebook application and not by any other application. The solution is to execute the magic command %matplotlib inline. This instructs the jupyter kernel to send an output that can be displayed inline.

It is assumed that most developers will have matplotlib installed, if not you will see a message similar to the following:Failed to execute kernel startup code. Details: ImportError: No module named matplotlib.This could be avoided if you changed the startup code as follows (either in user or worksapce settings):

If on the other hand, you had some standard code to be executed you could always update it as follows:Each line of code as a separate item.

Displaying results

Visual Studio Python Config File

By default results are appended in the results window.This behaviour could be changed such that previous resuls are cleared when displaying the latest results.

Vs Code Vs Visual Studio Python

As in any other case, this could be configured either in the user or worksapce settings as follows: