Skip to main content

Command Palette

Search for a command to run...

Python Development Environment on WSL2

Updated
โ€ข2 min readโ€ขView as Markdown
Python Development Environment on WSL2

This Post guides you through how to setup a python development environment on Windows Sub-System for Linux(wsl2).

What is WSL2?

wsl2 lets a windows user use a virtual linux environment on Windows Machine itself. This is pretty handy feature for quick development needs on your local machine.

Below Steps would list what all are the pre-requisites for achieving a python development environment on Windows Machine:

  • Installing WSL2: https://learn.microsoft.com/en-us/windows/wsl/install

  • Install Microsoft Visual Studio code for Windows platform: https://code.visualstudio.com/

  • Install the Remote WSL Extension on VSCode: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl

  • Once Wsl2 (at step 1) in installed open an Ubuntu terminal and verify if Python3 is installed using python3 --version.

  • If Python3 is not installed then do the following:

sudo apt update
sudo apt install python3 python3-pip python3-venv

NOTE : Above command will install python3 , pip tool and python virtual environment package.

  • To create a Virtual Environment Open the WSL2 Terminal and create your python project directory using command mkdir <YOUR_PROJECT_NAME> and then inside create virtual environment using python3 -m venv .venv and to activate the environment run source .venv/bin/activate where .venv is your virtual environment name.

NOTE: Recommendation is creating the virtual environment inside the directory in which you plan to have your project. Since each project should have its own separate directory, each will have its own virtual environment, so there is not a need for unique naming

  • To exit from virtual environment run on wsl2 terminal: deactivate

Reference: https://learn.microsoft.com/en-us/windows/python/web-frameworks

More from this blog

DevSecOps for Infrastructure as Code

This post provides information about building a DevSecOps pipeline for your Infra as Code setup. ๐Ÿ“๐‚๐จ๐ฆ๐ฉ๐จ๐ง๐ž๐ง๐ญ๐ฌ ๐”๐ฌ๐ž๐: GitHub Actions: As CI/CD platform. HashiCorp Terraform: Tool for Infra as Code. ๐’๐ญ๐š๐ญ๐ข๐œ ๐‚๐จ๐๐ž ๐€๐ง๐š๐ฅ๐ฒ๐ฌ๐ข๏ฟฝ...

Aug 25, 20251 min read
DevSecOps for Infrastructure as Code

Local LLM's on WSL2

Below example demonstrates running locally Ollama and ๐Ž๐ฉ๐ž๐ง-๐–๐ž๐›๐”๐ˆ ๐จ๐ง ๐š ๐–๐’๐‹2 containerized environment. - The model Ollama is running in this example: ๐๐ฐ๐ž๐ง2.5-๐‚๐จ๐๐ž๐ซ:0.5๐› - Presently it is on CPU as i have ๐ˆ๐ง๐ญ๐ž๐ฅ ๐ˆ๐ซ๐ข๏ฟฝ...

Jun 7, 20251 min read
Local LLM's on WSL2

lostinopensrc Blogs!

25 posts