Last modified: May 26, 2025 By Alexander Williams
Install Python on WSL in Easy Steps
Windows Subsystem for Linux (WSL) lets you run a Linux environment on Windows. Installing Python on WSL is simple. Follow these steps.
Prerequisites
Before installing Python, ensure WSL is set up. Open PowerShell as admin and run:
wsl --install
This installs the default Linux distribution (usually Ubuntu). Reboot if needed.
Update Package List
Launch your WSL terminal. Update the package list to get the latest versions:
sudo apt update
This ensures you install the most recent Python version available.
Install Python
Python is often pre-installed on WSL. Check with:
python3 --version
If not installed, use:
sudo apt install python3
For pip (Python package manager), run:
sudo apt install python3-pip
Verify Installation
Confirm Python and pip are working:
python3 --version
pip3 --version
You should see version numbers. If not, recheck the steps.
Set Up a Virtual Environment
Virtual environments keep projects isolated. Install venv
:
sudo apt install python3-venv
Create a virtual environment:
python3 -m venv myenv
Activate it:
source myenv/bin/activate
Install Python Packages
With the environment active, install packages using pip:
pip install numpy pandas
For more advanced setups, check Install Multiple Python Versions with pyenv.
Alternative: Install Anaconda
For data science, Anaconda is a great choice. Download the Linux installer and run:
bash Anaconda-latest-Linux-x86_64.sh
Follow the prompts. Anaconda includes Python and many useful libraries.
Conclusion
Installing Python on WSL is straightforward. Update packages, install Python, and set up a virtual environment. Now you're ready to code!
For other platforms, see Install Python on Ubuntu or Install Python on macOS.