Windows for Data Science? Part I: What is WSL2 and How To Install It

A Comprehensive Guide for Setting Up the Perfect Machine Learning Environment on Windows 10

Brian Ross
4 min readFeb 21, 2020

--

Windows has long been the laughing-stock of the Python community, but in recent years Microsoft has undergone somewhat of a re-branding, and despite the hecklers in the back I will go ahead and call it now Windows is hands down “The Platform for Developers”.

In this multi-part guide I will show you how to enjoy the same calm, cool experience that many Linux and Mac users have — from the comfort of your Windows 10 machine.

What is WSL2?

Python development on Windows can be at best uncomfortable. Getting your environment to run smoothly is no easy task. While managing environments with Anaconda definitely makes things easier, in my experience it wasn’t enough. Enter WSL2, which uses virtualization technology to allow you to run a Linux kernel inside your Windows 10 installation, in fact future versions of Windows will ship with their own Linux kernel developed specifically for WSL2.

From the Microsoft Dev Blog:

Yes, you did just read that heading correctly! We will be shipping a real Linux kernel with Windows that will make full system call compatibility possible…This kernel has been specially tuned for WSL 2. It has been optimized for size and performance to give an amazing Linux experience on Windows. We will service this Linux kernel through Windows updates, which means you will get the latest security fixes and kernel improvements without needing to manage it yourself…this Linux kernel will be fully open source! When we release WSL 2 we will have the full configuration available online on Github, so you can see how it works and build it yourself.

Just like that all the arguments against Python development on Windows disappear.

Getting Started

For now WSL2 is only available through the Window’s Insider Program, which allows you to install preview builds of future Window’s updates. Go register for the Windows Insider Program, then navigate to the Updates and Security section of Settings, on the side panel you will see Windows Insider Program.

From here you can link your Windows Insider Account to your system and select your Insider settings (slow ring). If your system is not current on updates Windows will first install the updates required to bring it to the current build and then begin upgrading to the slow ring build. Your system will restart several times. On one of these restarts you should enable virtualization in the BIOS settings. The location of this setting is specific to your system, mine was found under the security menu.

Getting your Linux On

You will need to enable two features before you can install your first Linux distro on your machine. The easiest way to do this is through PowerShell. Open the Start menu and navigate to the Windows PowerShell folder, right-click on Windows PowerShell then under “more” select Run as administrator.

The first feature you need to enable is WSL1. To do this copy and paste the following into the PowerShell window you just opened.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

After that reboot your system. When you come back open the PowerShell as administrator again and copy and paste the following

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Then reboot your system again, and one last time open the PowerShell as adminstrator and enter the following

wsl --set-default-version 2

Now you’re ready to install your first distro.

Installing a Linux Distro

If this is your first interaction with Linux then I suggest installing Ubuntu as your first distro, this will provide the friendliest experience as you learn the ins and outs of this entirely new OS. Head over to the Windows Store. In the search bar type in Linux, and you’ll be greeted by the following:

Click the blue button and on the next window click Ubuntu, and then click install. Once that’s done go ahead and click launch a terminal will pop up and…

Not in Kansas anymore

Pick a username and password (don’t forget to familiarize yourself with Linux Username Conventions), and welcome to the new world.

In Part II we will go over installing Miniconda and configuring Git and VS Code to work flawlessly with your new WSL2 Distro.

--

--

Brian Ross

Primarily interested in the intersection of advancements in data science and public good. linkedin.com/in/brianthomasross