Install Python 3.9.1 on WSL

visibility 7,509 comment 5 event 2022-01-08 access_time 9 months ago language English
more_vert

This article summarizes the steps to install Python 3.9.1 on Windows Subsystem for Linux Debian distro. You can also apply them to other similar distros. 

Installation steps

Run the following commands in your WSL terminal.

1) Update package lists

sudo apt update

2) Install dependent libraries

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev

3) Download Python binary package

wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz

4) Unzip the package

tar -xzf Python-3.9.1.tgz

5) Execute configure script

cd Python-3.9.1

./configure --enable-optimizations

6) Build Python 3.9

make -j 2

7) Install Python 3.9

sudo make install

Verify the installation

Run the following command to install Python 3.9:

$ python3.9
Python 3.9.1 (default, Jan 8 2022, 14:44:10)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

Make Python 3.9 the default

If you want to make Python 3.9 the default python program, you can follow these steps:

1) Change ~/.bashrc file to add the following line:

alias python='/usr/local/bin/python3.9'

2) And then run the following command to make it effective:

source ~/.bashrc

You can verify it using python command directly:

python --version

Python 3.9.1

References

info Last modified by Raymond 9 months ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts