Jupyter

Jupyter, or officially Project Jupyter, is an open-source project aimed to support interactive data science and scientific computing across all programming languages.
In this post I’ll go through my favorite setup for Jupyter using VS Code and go through a few examples in F# and Python.

Setup

Install Packages

Install scoop
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
Install Git
scoop install git
Install GitHub CLI
scoop install gh
Install pyenv
scoop install pyenv
Install .NET SDK
scoop install dotnet-sdk
Install VS Code
scoop install vscode

Create a Repository

Storing notebooks in GitHub is a great way to keep track of your work and share your work with others. GitHub can render the notebooks and markdown which makes it easy to browse and view notebooks from anywhere.
cd /repos/github/<GitHub username>
git init notebooks
cd notebooks
gh repo create
Follow the prompts to finish creating the repo.

Create a Python Virtual Environment

This will be the Python environment we will use to connect to the Jupyter server. We can install any python packages we plan to use (e.g., pandas) in this environment.
Install Python
pyenv install 3.8.2pyenv rehash
rehash just updates your PATH
Specify the Python version for your project.
pyenv local 3.8.2
This creates a .python-version file.
Create a virtual environment.
python -m venv --prompt notebooks .venv
This will create a directory .venv with the virtual environment.
Activate your virtual environment.
.venv/Scripts/activate
Update pip
python -m pip install --upgrade pip
Install Jupyter
pip install jupyter

Python Usage

Open VS Code
code .
Create a new file called python.ipynb.
Type Ctrl-Shift-P and start typing select kernel. Choose Notebook: Select Notebook Kernel
Select the Kernel for the Python environment which you created above.
Write some Python code and type Ctrl-Enter to run it.

F# Usage

First install the .NET Interactive Notebooks extension.
Create a new notebook called fsharp.ipynb.
Select the .NET Interactive kernel.
Write some F# code and type Ctrl-Enter to run it.

Git Usage

Save your notebooks and then click the Git extension and stage your changes.
Add a message describing your changes and then commit.
Lastly, push your changes to GitHub.

Summary

In this post I went through my favorite Jupyter setup and how you could write both Python and F# using VS Code. I also went through how you can store your notebooks in GitHub so you can easily share with others. To see the the finished product check out my repo https://github.com/ameier38/notebooks.