See also my post on setting up a Git development environment and R on Windows.

Windows without WSL

  1. Check if you have Windows Terminal installed. If not, install it from the Microsoft Store.

  2. Launch a Windows Terminal instance. This should start a PowerShell session.

  3. Update the PowerShell execution policy by running the following command:

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
  4. Run Get-ExecutionPolicy to check if it is set to RemoteSigned. If not, try setting it again in a terminal with administrative rights.

  5. Check if winget (the Windows package manager) is installed. The following command should bring up details about winget. If not, install it from the Microsoft Store.

    winget --help

    When using winget for the first time, you will be asked to accept some terms and conditions.

  6. Install a text editor. We will use Visual Studio Code.

    winget install vscode
  7. Find an appropriate Python version to install using the following command.

    winget search --tag python --cmd python --source winget

    This will output the following:

    Name            Id                  Version     Match
    Python 3        Python.Python.3.9   3.9.13      Tag: python
    Python 3.12     Python.Python.3.12  3.12.0      Tag: python
    Python 3.11     Python.Python.3.11  3.11.6      Tag: python
    Python 3.10     Python.Python.3.10  3.10.11     Tag: python
    Python 2        Python.Python.2     2.7.18150   Tag: python
    Python Launcher Python.Launcher     3.12.0      Tag: python
    Miniconda3      Anaconda.Miniconda3 py39_4.10.3 Tag: python
    Anaconda3       Anaconda.Anaconda3  2023.09     Tag: python
  8. Install Python. At the time of writing this guide, the latest version was 3.12, so I am installing 3.11.

    winget install python.python.3.11
  9. Check if Python was installed correctly. This command should display the version.

    py --version
  10. Launch Visual Studio Code and install the following extensions:

  11. Create a project folder, e.g. in C:\User\Username\Documents\project_folder.

  12. Create a virtual environment in the project folder.

    cd C:\User\Username\Documents\project_folder
    py -m venv .venv
  13. Install appropriate packages (e.g. JupyterLab) in the virtual environment.

    py -m pip install --upgrade pip
    py -m pip install jupyterlab matplotlib pandas
  14. Create an example Jupyter Notebook in the project folder, e.g. my_notebook.ipynb.

  15. Try to open the notebook using either VS Code or JupyterLab. To launch JupyterLab, run the following in the terminal from the project folder, which will launch a web browser instance:

    jupyter lab
  16. Activate the kernel in the Jupyter notebook and start coding!

Windows Subsystem for Linux (WSL) - Ubuntu

  1. In PowerShell, install Visual Studio Code and WSL (Ubuntu):

    winget install vscode
    wsl --install
  2. Install the WSL VS Code extension locally in Windows.

  3. Launch an Ubuntu Bash shell instance from Windows Terminal.

  4. Python should already be installed; check its version:

    python --version

    Note that it’s python on Ubuntu, not py.

  5. Launch VS Code using the WSL shell from the project folder’s directory:

    cd C:/User/Username/Documents/project_folder
    code .
  6. Install local VS Code extensions (e.g. Python and Jupyter) in WSL.

  7. Set-up a virtual environment in the project folder and install relevant packages:

    python3 -m venv .venv
    source .venv/bin/activate
    python3 -m pip install --upgrade pip
    python3 -m pip install jupyterlab matplotlib pandas

Further reading