Scott Hanselman

Announcing .NET Jupyter Notebooks

November 06, 2019 Comment on this post [14] Posted in DotNetCore | Open Source
Sponsored By

Graphs in Jupyter NotebooksJupyter Notebooks has been the significant player in the interactive development space for many years, and Notebooks have played a vital role in the continued popularity of languages like Python, R, Julia, and Scala. Interactive experiences like this give users with a lightweight tool (I like to say "interactive paper") for learning, iterative development, and data science and data manipulation.

The F# community has enjoyed F# in Juypter Notebooks from years with the pioneering functional work of Rick Minerich, Colin Gravill and many other contributors!

As Try .NET has grown to support more interactive C# and F# experiences across the web with runnable code snippets, and an interactive documentation generator for .NET Core with the dotnet try global tool, we're happy to take that same codebase to the next level, by announcing C# and F# in Jupyter notebooks.

.NET in Jupyter Notebooks

Even better you can start playing with it today, locally or in the cloud!

.NET in Anaconda locally

Install the .NET Kernel

Please note: If you have the dotnet try global tool already installed, you will need to uninstall the older version and get the latest before grabbing the Jupyter kernel-enabled version of the dotnet try global tool.

  • Check to see if Jupyter is installed

    jupyter kernelspec list

  • Install the .NET kernel!

    dotnet try jupyter install

    dotnet try jupyter install

  • Test installation

    jupyter kernelspec list

    You should see the .net-csharp and .net-fsharp listed.

jupyter kernelspec list
  • To start a new notebook, you can either type jupyter lab Anaconda prompt or launch a notebook using the Anaconda Navigator.

  • Once Jupyter Lab has launched in your preferred browser, you have the option to create a C# or a F# notebook

.NET C# and F# in Jupyter Notebooks
  • Now you can write .NET and and prose side by side, and just hit Shift-Enter to run each cell.

    Example C# code in Jupyter Notebooks

For more information on our APIs via C# and F#, please check out our documentation on the binder side or in the dotnet/try repo in the NotebookExamples folder.

C# and F# samples and docs


To explore some of the features that .NET notebooks ships with, I put together dashboard for the Nightscout GitHub repo.

HTML output : By default .NET notebooks ship with several helper methods for writing HTML. From basic helpers that enable users to write out a string as HTML or output Javascript to more complex HTML with PocketView. Below I'm using the display() helper method.


Importing packages : You can load NuGet packages using the following syntax. If you've used Rosyln-powered scripting this #r for a reference syntax will be familiar.

#r "nuget:<package name>,<package version>"

For Example

#r "nuget:Octokit, 0.32.0"
#r "nuget:NodaTime, 2.4.6"
using Octokit;
using NodaTime;
using NodaTime.Extensions;
using XPlot.Plotly;

Do note that when you run a cell like this with a #r reference that you'll want to wait as that NuGet package is installed, as seen below with the ... detailed output.

installing nuget packages in Jupyter Notebooks

Object formatters : By default, the .NET notebook experience enables users to display useful information about an object in table format.

The code snippet below will display all opened issues in the nightscout/cgm-remote-monitor repo.

display(openSoFar.Select(i => new {i.CreatedAt, i.Title, State = i.State.StringValue,  i.Number}).OrderByDescending(d => d.CreatedAt));

With the object formatter feature, the information will be displayed in a easy to read table format.

Querying the Nightscout repository


Visualization is powerful storytelling tool and,a key feature of the Jupyter notebook experience. As soon as you import the wonderful XPlot.Plotly F# Visualization Package into your notebooks(using Xplot.Ploty;) you can begin creating rich data visualizations in .NET.

The graphs are interactive too! Hover over the different data points to see the values.

Issue report over the last year

Learn, Create and Share

To learn, create and share .NET notebooks please check out the following resources:

  • Learn: To learn online checkout the dotnet/try binder image for a zero install experience.
  • Create: To get started on your machine check out the dotnet/try repo. Select the option highlighted option
  • Share: If you want to share notebooks you have made using the .NET Jupyter kernel, the easiest way is to generate a Binder image that anyone can run on the web. For more information on how to do this please check out the .NET Jupyter documentation.

Checkout the online .NET Jupyter Notebook I created for to explore the NightScout GitHub project using C# and the Octokit APIs.

We hope you enjoy this new .NET Interactive experience and that you're pleasantly surprised by this evolution of the .NET Try interactive kernel.

Sponsor: Octopus Deploy wanted me to let you know that Octopus Server is now free for small teams, without time limits. Give your team a single place to release, deploy and operate your software.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
November 08, 2019 15:00
Awesome development. I really wanted a good JupyterKernel for C# for a long long time now. I also tried to write my own :)

ICSharp.Kernel github

Does this official kernel have a Github repo? I would love to contribute...

November 08, 2019 15:38
@gyurisc this is hosted in the Try .NET repository:


and it'd be great to have more community contributions
November 08, 2019 18:57
Scott, please, ask MS to decrease its magical stuff delivery speed. Before digging into something, another miracle comes to the playground.

Such a great job. Congrats.
November 09, 2019 16:30
Really great achievement. This builds a bridge between development and data science. Would be cool if C# Notebooks could be edited in Visual Studio Code as python ones are.
November 09, 2019 17:09
Аренда строительной техники по лучшей цене

[url=]бетононасосы автомобильные[/url]
November 10, 2019 5:46
Scott, you know your community! One big .NET happy family :-) F# and C# for the win!
November 11, 2019 14:52
How does this compare with LinqPad? I use that all the time for simple exploratory work, and the almost-universal `.Dump()` extension methods are brilliant for data display (Though, admittedly, not as nice graphically as this one).

I'm a little cautious because every time I've tried to install Python on my PC, I've ended up breaking the installation, ripping it out and giving up :P
November 12, 2019 0:04
This is wonderful. Hoping there efforts to get Intellisense and debuggging working. Someday, with client-side Blazor, we could in-line these interactive tools right in the post. Hope this project takes off. Would love to help! Posted as well.
November 13, 2019 11:26
Hi all of you.
I want to share by a Binder image my c# notebooks and I followed this tuto:

This tuto

Everything ok, but when I open my badge/Binder image there´s no kernel installed!!, but the Dockerfile was ok, the builder I think its also ok and if I check the jupyter terminal theres only one kernel!!(the python default). So it is placing the kernels in the wrong way?? Becasue if you do locally it place the kernel in a differente place but it is able to read it! I mean:
`Anacaconda prompt`
(base) C:\Users\enrique.cervino>jupyter kernelspec list
Available kernels:
.net-csharp C:\Users\enrique.cervino\AppData\Roaming\jupyter\kernels\.net-csharp
.net-fsharp C:\Users\enrique.cervino\AppData\Roaming\jupyter\kernels\.net-fsharp
python3 C:\Users\enrique.cervino\AppData\Local\Continuum\anaconda3\share\jupyter\kernels\python3
Local & Roaming?? In local is able to recognise that but in remote maybe it isnt??
I have made two questions on `Reddit` and `Stackoverflow`, here the links with images:



November 13, 2019 15:02
I fixed, the linsk above(reddit and stack) give you the answer, but in a simple way better start the dockerfile with and specific image and not use the tag `lasted´
something like:

FROM jupyter/scipy-notebook:45f07a14b422

from the binder docs:

Here’s an example of a Dockerfile FROM statement that would work.

FROM jupyter/scipy-notebook:cf6258237ff9

The following examples would not work:

FROM jupyter/scipy-notebook


FROM jupyter/scipy-notebook:latest
November 13, 2019 21:53
Why wasn't C# and F# included with Azure Data Studio?
November 15, 2019 2:40
This is really cool!

Is it something Microsoft is officially supporting or a side-project?
November 16, 2019 22:02
Installation instructions are confusing.

In this part:
.NET Core 3.0 SDK and 2.1 as currently the dotnet try global tool targets 2.1.

What am I supposed to install? 3.0 SDK? 2.1? both?
Can you create a working Docker image with Jupyter/.Net?
October 18, 2020 7:07
Wow, fantastic blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your site
is great, let alone the content!

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.