WSL2 – Windows Subsystem for Linux Installation Guide for Windows 10

Old: [Windows Subsystem for Linux Installation Guide for Windows 10]

Hyper-V needs to be [enabled in the BIOS] otherwise you may see an error.
Installing, this may take a few minutes…
WslRegisterDistribution failed with error: 0x80370102
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/enablevirtualization

First open PowerShell Admin console to enable the Windows Subsystem for Linux.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

In the PowerShell Admin console, enable the Virtual Machine feature.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Reboot.

WSL2: [Download the Linux kernel update package]

In the PowerShell Admin console, set WSL2 as your default version.

wsl --set-default-version 2

Reboot

Install your Linux version from the Microsoft Store.

In the terminal check that the version is WSL2.

PS C:\WINDOWS\system32> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

[Get started using Python for web development on Windows]

[VS Code: Developing in WSL]

Open a WSL terminal in VS Code by opening Terminal->New Terminal and enter wsl in the terminal.

[Configure WSL for C/C++ Debugging]

Enable libc debugging in VS Code.

sudo mkdir /build
sudo mkdir /build/glibc-ZN95T4
sudo cd /build/glibc-ZN95T4
sudo tar xvf /usr/src/glibc/glibc-2.31.tar.xz