Guide to Installing and Using WSL2 for Python Development on Windows
This article provides a comprehensive step‑by‑step guide to installing Windows Subsystem for Linux 2 (WSL2), configuring Ubuntu, integrating development tools such as VS Code, Windows Terminal, Miniconda, and demonstrates how to efficiently work across Windows and Linux environments for Python development.
In 2016 Microsoft introduced Windows Subsystem for Linux (WSL) and in May 2019 released WSL2 with a new architecture that dramatically improves file‑system performance. The author, who has followed WSL for a while, decided to install and test WSL2, highlighting its power as a development platform when combined with a full Linux distribution such as Ubuntu.
The article outlines three main topics: what WSL is and why to use it, how to install WSL2 with helpful auxiliary applications, and how to make Python work efficiently in a combined Windows‑Linux environment.
What is WSL? WSL lets you run a genuine Linux distribution on Windows, providing near‑bare‑metal speed and full Unix command support while still allowing access to Windows tools like Office. It uses a lightweight Hyper‑V subset, enabling fast startup (about one second) and seamless file sharing between the two environments.
Installing WSL2 – The guide assumes you have administrator rights and are enrolled in the Windows Insider Program. After ensuring you are on at least build 18917, you enable the "Windows Subsystem for Linux" and "Virtual Machine Platform" features via PowerShell: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform After a reboot, you install a Linux distribution (Ubuntu) from the Microsoft Store, set a username/password, and update the Linux environment with: sudo apt update && sudo apt upgrade -y Finally, you upgrade the installed distro to WSL2: wsl --set-version Ubuntu-18.04 2 and set WSL2 as the default version for future installations: wsl --set-default-version 2 .
Helper Applications – The author recommends installing Windows Terminal (via the Microsoft Store) for a better command‑line experience, Miniconda for managing Python environments on both Windows and WSL, and Visual Studio Code with the Remote‑WSL, Python, and Anaconda Extension Pack extensions. The VS Code Remote‑WSL extension allows you to edit files inside the Linux filesystem directly from the Windows VS Code UI.
Cross‑Environment Workflow – Files can be accessed from Windows Explorer using the \wsl$\Ubuntu\home\username path or by running explorer.exe from the Ubuntu shell. The article warns against manipulating the AppData folder directly from WSL. It also shows how to run graphical Linux applications by installing an X server (e.g., VcXsrv) on Windows and configuring .bashrc accordingly.
Running Applications – The wsl command can launch Linux executables directly from PowerShell, and Jupyter Notebook can be started in WSL with the --no-browser flag, then accessed from a Windows browser. The guide also demonstrates installing and running GUI tools like Trimage and a lightweight desktop environment (xfce) for more complex graphical workloads.
Typical Workflow – The author lists a personal setup: Chrome for browsing, VS Code for editing, Visual Studio for long‑form writing, Ubuntu on WSL for blog generation and command‑line tools, and separate Conda environments on both Windows and WSL to keep Python dependencies isolated.
Conclusion – WSL2 bridges the gap between Windows and Linux, allowing developers to enjoy the strengths of both ecosystems. By following the guide, readers can create a robust, Python‑focused development environment that leverages Windows tools, Linux command‑line power, and seamless cross‑platform integration.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.