Installation guide
Learn how to install Go and Python.
Installation guide
This guide provides step-by-step instructions to install Go and Python on WSL 2 with Ubuntu 24.04 as the default distribution.
Prerequisites (if necessary)
-
Enable WSL 2
- Open PowerShell as Administrator and run
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart - Restart your system.
- Open PowerShell as Administrator and run
-
Install WSL 2 and Ubuntu 24.04
- Run the following commands in PowerShell
wsl --set-default-version 2 wsl --install -d Ubuntu-24.04 - Set up a username and password when prompted.
- Run the following commands in PowerShell
-
Update Ubuntu
- Open the Ubuntu terminal and run
sudo apt update && sudo apt upgrade -y
- Open the Ubuntu terminal and run
-
Install necessary tools
- Open the Ubuntu terminal and run
sudo apt install git
- Open the Ubuntu terminal and run
Installing Go
Step 1: Download Go
- Visit the official Go download page to get the latest version.
- Alternatively, download it directly in the terminal
curl -OL https://go.dev/dl/go1.24.2.linux-amd64.tar.gz
Step 2: Install Go
Remove any previous Go installation:
sudo rm -rf /usr/local/go
Extract the downloaded tarball to /usr/local
sudo tar -C /usr/local -xzf go1.24.2.linux-amd64.tar.gz
Step 3: Configure environment variables
Open the .profile file:
vi ~/.profile
Add the following lines
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
Save and apply the changes
source ~/.profile
Step 4: Verify installation
Run the following command to check the Go version
go version
Installing Python
Step 1: Verify and optionally install Python 3
Python 3 should already be installed in Ubuntu. Verify with the following command
python3 --version
If the command fails install with
sudo apt install python3
Verify again
python3 --version
Step 2: Install pip
Install Pip, the Python package manager
sudo apt install -y python3-pip
Verify the pip installation
pip3 --version
Step 3: Set up virtual environments
Install the venv module
sudo apt install python3-venv
Create a virtual environment
python3 -m venv myenv
Activate the virtual environment
source myenv/bin/activate