Skip to content

Windows Linux Subsystem dev setup

vomJupiter edited this page May 5, 2022 · 16 revisions

How to setup a Python development environment on Windows 10?

This is an opinionated guide for a science-oriented development setup on Windows 10.

Table of contents

Windows Subsystem for Linux (WSL)

The Windows Linux subsystem allows for taking advantage of some of the open-source-based development ease of the Linux World while staying in the Windows world. This will give you a CLI for Ubuntu only, however. If you want to get the full graphical desktop experience, we recommend to install Ubuntu, or one of its derivatives (Xubunut, Mint, etc.) as a dual-boot-system.

To get your Linux-based setup in Windows 10, follow these steps:

  • Install the Windows Linux Subsystem (WSL) v2
    • In case you are experiencing issues with this step, here is some additional troubleshooting advice: login with your admin account and check again for updates; make sure to execute the kernel update as admin; if the kernel update doesn't execute, de-install and reinstall it
  • Install Ubuntu in WSL
  • Start, update and upgrade Ubuntu: sudo apt update, 'sudo apt upgrade'

Pipenv (Pragmatic Installation)

Pipenv allows you to separate and reproducibly document the Python environments you are working in for different projects.

Visual Studio Code

Visual Studio Code is a highly customisable code and text editor that is able to deliver an IDE-like experience via a vast ecosystem of extensions for all popular programming languages.

  • Install Visual Studio Code in Windows
  • Install WSL extension for VSC
  • Install Python extension for VSC

Package Installation and Environment Setup:

  • Go to your project directory and install the packages as required.
  • This will create a new environment for your project.
  • Select this new environment in the drop-down list when prompted for python interpreter.

Jupyter Lab

While VS Code has also extensions for Jupyter Notebooks (a browser-based platform for interactive programming in several languages, like Julia, Python, and R), Jupyter Lab is more powerful, and closer to what you will be most likely to share with colleagues and/or the public to make your research transparent.

Here is a short guide on best practices for getting and working with it:

How to work in Jupyter Lab

Miniconda (optional)

Install Miniconda, an alternative to pipenv that is sometimes preferable, depending on your projects dependencies.

  • Install Miniconda within Ubuntu
  • run conda config --set auto_activate_base false so that conda does not automatically activate (and messes up environments that you might have created in pipenv or similar)
  • Create a conda env to get a python virtual environment

Docker (optional)

Docker allows to virtualise whole operating systems, which makes it suitable for the development of larger software projects that are meant to be reproducibly deployed in a server environment and encompass several pieces of software (e.g. data collection tools, databases, and data analysis tools) requiring complex, entangled setups.

Clone this wiki locally