Visual Studio Code Jupyter



Python visual-studio-code jupyter-notebook anaconda. Improve this question. Follow edited Nov 16 '20 at 10:56. 366 2 2 silver badges 14 14 bronze badges. Asked Nov 16 '20 at 4:51. Mattias Weiland Mattias Weiland. 21 3 3 bronze badges. Working with Jupyter Notebooks in Visual Studio Code. Jupyter (formerly IPython Notebook) is an open-source project that lets you easily combine Markdown text and executable Python source code on one canvas called a notebook. Visual Studio Code supports working with Jupyter Notebooks natively, as well as through Python code files. This topic covers the native support available for Jupyter Notebooks. Working with Jupyter Notebooks in Visual Studio Code Jupyter (formerly IPython Notebook) is an open-source project that lets you easily combine Markdown text and executable Python source code on one canvas called a notebook. Visual Studio Code supports working with Jupyter Notebooks natively, as well as through Python code files.

Jupyter (formerly IPython Notebook) is an open-source project that lets you easily combine Markdown text and executable Python source code on one canvas called a notebook. Visual Studio Code supports working with Jupyter Notebooks natively, as well as through Python code files. This topic covers the support offered through Python code files and demonstrates how to.

-->

In this article, you'll learn how to connect to an Azure Machine Learning compute instance using Visual Studio Code.

Visual Studio Code Jupyter

An Azure Machine Learning Compute Instance is a fully managed cloud-based workstation for data scientists and provides management and enterprise readiness capabilities for IT administrators.

There are two ways you can connect to a compute instance from Visual Studio Code:

  • Remote compute instance. This option provides you with a full-featured development environment for building your machine learning projects.
  • Remote Jupyter Notebook server. This option allows you to set a compute instance as a remote Jupyter Notebook server.

Configure a remote compute instance

To configure a remote compute instance for development, you'll need a few prerequisites.

  • Azure Machine Learning Visual Studio Code extension. For more information, see the Azure Machine Learning Visual Studio Code Extension setup guide.
  • Azure Machine Learning workspace. Use the Azure Machine Learning Visual Studio Code extension to create a new workspace if you don't already have one.
  • Azure Machine Learning compute instance. Use the Azure Machine Learning Visual Studio Code extension to create a new compute instance if you don't have one.

To connect to your remote compute instance:

Azure Machine Learning Extension

  1. In VS Code, launch the Azure Machine Learning extension.
  2. Expand the Compute instances node in your extension.
  3. Right-click the compute instance you want to connect to and select Connect to Compute Instance.

Command Palette

  1. In VS Code, open the command palette by selecting View > Command Palette.
  2. Enter into the text box Azure ML: Connect to Compute Instance.
  3. Select your subscription.
  4. Select your workspace.
  5. Select your compute instance or create a new one.

Navigate to ml.azure.com

Code

Important

In order to connect to your remote compute instance from Visual Studio Code, make sure that the account you're logged into in Azure Machine Learning studio is the same one you use in Visual Studio Code.

Visual Studio Code Jupyter

Compute

  1. Select the Compute tab
  2. In the Application URI column, select VS Code for the compute instance you want to connect to.

Notebook

  1. Select the Notebook tab
  2. In the Notebook tab, select the file you want to edit.
  3. Select Editors > Edit in VS Code (preview).

A new window launches for your remote compute instance. When attempting to make a connection to a remote compute instance, the following tasks are taking place:

  1. Authorization. Some checks are performed to make sure the user attempting to make a connection is authorized to use the compute instance.
  2. VS Code Remote Server is installed on the compute instance.
  3. A WebSocket connection is established for real-time interaction.

Once the connection is established, it's persisted. A token is issued at the start of the session which gets refreshed automatically to maintain the connection with your compute instance.

After you connect to your remote compute instance, use the editor to:

  • Author and manage files on your remote compute instance or file share.
  • Use the VS Code integrated terminal to run commands and applications on your remote compute instance.

Configure compute instance as remote notebook server

Jupyter Notebook Vs Code

In order to configure a compute instance as a remote Jupyter Notebook server you'll need a few prerequisites:

  • Azure Machine Learning Visual Studio Code extension. For more information, see the Azure Machine Learning Visual Studio Code Extension setup guide.
  • Azure Machine Learning workspace. Use the Azure Machine Learning Visual Studio Code extension to create a new workspace if you don't already have one.
Visual studio code jupyter venv

To connect to a compute instance:

  1. Open a Jupyter Notebook in Visual Studio Code.

  2. When the integrated notebook experience loads, select Jupyter Server.

    Alternatively, you also use the command palette:

    1. Open the command palette by selecting View > Command Palette from the menu bar.
    2. Enter into the text box Azure ML: Connect to Compute instance Jupyter server.
  3. Choose Azure ML Compute Instances from the list of Jupyter server options.

  4. Select your subscription from the list of subscriptions. If you have have previously configured your default Azure Machine Learning workspace, this step is skipped.

  5. Select your workspace.

  6. Select your compute instance from the list. If you don't have one, select Create new Azure ML Compute Instance and follow the prompts to create one.

  7. For the changes to take effect, you have to reload Visual Studio Code.

  8. Open a Jupyter Notebook and run a cell.

Important

You MUST run a cell in order to establish the connection.

Vs Code Jupyter Notebook Shortcut

At this point, you can continue to run cells in your Jupyter Notebook.

Visual Studio Code Jupyter Debug

Tip

You can also work with Python script files (.py) containing Jupyter-like code cells. For more information, see the Visual Studio Code Python interactive documentation.

Visual Studio Code Jupyter Show Line Numbers

Jupyter

Visual Studio Code Jupyter Notebook

Next steps

Visual Studio Code Jupyter Autocomplete

Now that you've set up Visual Studio Code Remote, you can use a compute instance as remote compute from Visual Studio Code to interactively debug your code.

Tutorial: Train your first ML model shows how to use a compute instance with an integrated notebook.