Setup Jupyter Notebooks With .NET

The ML.NET logo with a robot face next to it.

3 Easy Steps

1. Download Juptyer Notebooks

Jupyter Notebooks is a product from Anaconda which allows you to run blocks of code in a notebook session. If you haven't seen it before, prepare to be impressed. Jupyter Notebooks is a great way to write code and explain that code along the way.

To download it, go here: Anaconda Downloads

Then click the link for the platform you use (I'm using Windows) and download the installer.

Running the installer will present you with a few options. The first option (should Anaconda3 be on the PATH) is not recommended and should probably not be selected. However the second option is a good choice if you have not already downloaded Python 3.8. (If you have and you attempt to select this then the installer will warn you.)

2. Add dotnet to Anaconda

After the installation is completed find the Anaconda prompt from the start menu and run it.

A screenshot of the anaconda prompt shortcut from the windows start menu.

Test to see if you have the .NET SDK installed by typing dotnet and pressing enter in the Anaconda prompt. You should see the .NET help options in the prompt:

A screenshot of the anaconda prompt where dotnet SDK is shown to be installed.

If you don't then you'll need to install that. Please note that the dotnet-interactive tool still only supports .NET 5.0 FYI. You can get the SDK here: Install .NET SDK

Next you'll need to install the dotnet-interactive tool. From the Anaconda prompt type this command: dotnet tool install -g --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" Microsoft.dotnet-interactive

A screenshot of the anaconda prompt where dotnet-interactive is successfully installed.

Following the successful installation of dotnet-try run this command: dotnet interactive jupyter install

A screenshot of the the .net kernels being installed

3. Test the .NET Installation in Jupyter Lab

Finally we can run jupyter lab from the Anaconda prompt and see the launcher which will allow us to easily create a new notebook using the runtime of our choice, Python, C#, F#, and PowerShell.

A screenshot of the running Jupyter lab

Click on .NET (C#) and test it out.

A screenshot C# running in Juypter Notebooks