WSL is taking over the world for Developers working on multiple Environments. I published in the past this guide on How to install python 3.11 on Ubuntu WSL and now is time for getting python 3.11 Installed and Revived.
First. Look at which Python you got.
At the time of my checking Ubuntu22.04 came with python 3.10
root@DESKTOP-9FOROU3:~# python3 --version
Python 3.10.12
root@DESKTOP-9FOROU3:~#
Preparation Steps, Updates and Dependencies.
First you want to get your packages updated and install some dependencies.
root@DESKTOP-9FOROU3:~# apt update && apt upgrade -y
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
DeadSnakes is the Repository that maintains the latest releases from Python for Ubuntu. Add the repository.
root@DESKTOP-9FOROU3:~# add-apt-repository ppa:deadsnakes/ppa
Repository: 'deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main'
Description:
This PPA contains more recent Python versions packaged for Ubuntu.
Install Python 3.12 (Latest) on Windows for Linux Subsystem WSL.
root@DESKTOP-9FOROU3:~# apt install python3.12
You should now be able to see the python version installed.
root@DESKTOP-9FOROU3:~# python3.12 --version
Python 3.12.1
Install PiPy
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
root@DESKTOP-9FOROU3:~# pip3.12 -V
pip 24.0 from /usr/local/lib/python3.12/dist-packages/pip (python 3.12)
Create a .venv in Python3.12
You should now be able to create more .venv Environments with Python 3.12
root@DESKTOP-9FOROU3:~# python3.12 -m venv .venv --without-pip
root@DESKTOP-9FOROU3:~# ls -lah
total 32K
drwx------ 6 root root 4.0K Feb 13 22:00 .
drwxr-xr-x 19 root root 4.0K Feb 13 21:03 ..
-rw-r--r-- 1 root root 3.1K Oct 15 2021 .bashrc
drwxr-xr-x 5 root root 4.0K Feb 13 22:00 .venv
root@DESKTOP-9FOROU3:~# source .venv/bin/activate
(.venv) root@DESKTOP-9FOROU3:~# python --version
Python 3.12.1
(.venv) root@DESKTOP-9FOROU3:~#
Look into our other WSL Content you might like
Here is some other WSL related content you might like. If you are a developer getting more familiar with WSL, this content might be for you.
Leave a comment