Skip to content

Latest commit

 

History

History
85 lines (52 loc) · 2.96 KB

File metadata and controls

85 lines (52 loc) · 2.96 KB
title Notebooks with Python Kernel in Azure Data Studio
description This tutorial shows how you can create and run a Python notebook.
author garyericson
ms.author garye
ms.reviewer mikeray, alayu, maghan
ms.topic tutorial
ms.prod sql
ms.technology azure-data-studio
ms.custom
ms.date 04/23/2020

Create and run a Python notebook

[!INCLUDEtsql-appliesto-ssver15-xxxx-xxxx-xxx]

This tutorial demonstrates how to create and run a notebook in Azure Data Studio using the Python kernel.

Prerequisites

New notebook

The following steps show how to create a notebook file in Azure Data Studio:

  1. Open Azure Data Studio. If you're prompted to connect to a SQL Server, you may connect or click Cancel.

  2. Select New Notebook in the File menu.

  3. Select Python 3 for the Kernel.

    :::image type="content" source="media/notebook-tutorial-python/set-kernel-and-attach-to-python.png" alt-text="Set Kernel":::

  4. If you're prompted to configure Python, then in Configure Python for Notebooks select either:

    • New Python installation to install a new copy of Python for Azure Data Studio, or
    • Use existing Python installation to specify the path to an existing Python installation

Run a notebook cell

You can create cells containing code or text. You can run a code cell in place and the results are shown in the notebook after the cell is finished running. Text cells allow you to intersperse formatted documentation with your code.

Code

Add a new Python code cell by selecting the +Code command in the toolbar.

:::image type="content" source="media/notebook-tutorial-python/notebook-toolbar-python.png" alt-text="Notebook toolbar":::

This example does simple math.

a = 1
b = 2
c = a/b
print(c)

Run the cell by clicking the play button to the left of the cell. The results appear below.

:::image type="content" source="media/notebook-tutorial-python/run-notebook-cell-python.png" alt-text="Run notebook cell":::

Text

Add a new text cell by selecting the +Text command in the toolbar.

:::image type="content" source="media/notebook-tutorial-python/notebook-toolbar-python-text.png" alt-text="Notebook toolbar":::

The cell changes to edit mode and you can now type markdown and see the preview at the same time.

:::image type="content" source="media/notebook-tutorial-python/notebook-markdown-cell-python.png" alt-text="Markdown cell":::

Selecting outside the text cell shows just the markdown text.

:::image type="content" source="media/notebook-tutorial-python/notebook-markdown-preview-python.png" alt-text="Markdown text":::

Next steps

Learn more about notebooks: