Nowadays there are many ways to run Linux/Windows to coexist. I recently started working on a new project gmail_unsubscriber for this I needed to revamp my environment setup and I needed python 3.11. Here are some steps to make it happen.
The default ubuntu on WSL is Ubuntu 20.04 and python3.8.
Install your Dependencies
First we need to install dependencies. This are required by the Python Packages we will install later.
sudo apt install build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
If you have trouble at this stage because you don’t remember your root password, dont worry I created this guide on how to reset your root password on WSL Ubuntu, in case you forgot it.
Add a ppa to the repository to be able to later install the python3.11 package
sudo add-apt-repository ppa:deadsnakes/ppa
Install Python 3.11
sudo apt install python3.11
You should now be able to see which python version you installed
robert@LAPTOP:/$ python3.11 --version
Python 3.11.3
Install PyPi
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
You might need to add the folder where pipy got installed to the path.
vi ~/.profile
export PATH="/home/robert/.local/bin:$PATH"
You can check now if pipy is installed
pip3.11 -V
pip 22.3.1 from /usr/local/lib/python3.11/dist-packages/pip (python 3.11)
Create a .venv in Python3.11
Inside your project you should now be able to create a .venv with python 3.11
robert@LAPTOP:/$ python3.11 -m .venv --without-pip venv
robert@LAPTOP:/$ ls
LICENSE README.md .venv
robert@LAPTOP:/$ source .venv/bin/activate
(.venv) root@DESKTOP-9FOROU3:~# python --version
Python 3.11.3
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