How to Setup Your First WSL Distro for Python Development β
In this time, we are going to use Debian distro which when this article is written has version 12. This blog article will explain the steps by Straight Through The Code, there is no much explanation that too long to read.
Installing WSL Distro β
wsl --install -d DebianAfter that, we need to input some configurations:
- New UNIX username
- Password
Setup Systemd for WSL β
It is best to config the systemd to your distro by this simple steps:
sudo nano /etc/wsl.confThen input these lines inside the file
[network]
generateResolvConf = false
[boot]
systemd = trueAlso, we need to setup the resolv.conf file for the DNS resolver
sudo nano /etc/resolv.confThen input these lines inside the file
nameserver 8.8.8.8
nameserver 1.1.1.1Then save it by Ctrl+S, then exit by Ctrl+X
Setup WSL Environment β
1. Setup standard library β
sudo apt-get update && apt-get upgrade -ysudo apt-get install -y --no-install-recommends ca-certificates netbase tzdatasudo apt-get install -y --no-install-recommends dpkg-dev gcc gnupg libbluetooth-dev libbz2-dev libc6-dev libdb-dev libexpat1-dev libffi-dev libgdbm-dev liblzma-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev make tk-dev uuid-dev wget xz-utils zlib1g-dev curl2. Setup Git β
sudo apt-get install -y git3. Setup Python β
# Install uv first for easy and python installation
curl -LsSf https://astral.sh/uv/install.sh | shThen, restart your shell/terminal to activate the new command uv.
uv python installto run the python, we should use uv python command not only python.
4. Setup PostgreSQL β
Install PostgreSQL from the repository
sudo apt-get install postgresql postgresql-contribTIP: Setting so PostgreSQL can be accessed by password
sudo nano /etc/postgresql/<version>/main/pg_hba.confbefore: local allpostgres peer
after: local all postgres md5
Check does the postgresql service has been started
# Checking service name, look for something like:
# postgresql@15-main.service
sudo systemctl list-units | grep postgresql
# Checking Status
systemctl status postgresql@15-main
# Start The Service
sudo systemctl start postgresql@15-main5. Clean The Installation Setup Files β
sudo rm -rf /var/lib/apt/lists/*