Skip to content

Instantly share code, notes, and snippets.

@CarlosDomingues
Last active January 13, 2022 18:50
Show Gist options
  • Save CarlosDomingues/59668f6f3d9f5716582ef13434317331 to your computer and use it in GitHub Desktop.
Save CarlosDomingues/59668f6f3d9f5716582ef13434317331 to your computer and use it in GitHub Desktop.
Python 3.10 on Ubuntu 20 on Windows 11

A guide on how to install Python 10 on WSL2 under Windows 10 / 11.

Install pyenv

pyenv is a tool that allows switching the global Python version, or choosing a specific version per project.

sudo apt update --yes
sudo apt install --yes build-essential curl git libbz2-dev liblzma-dev libffi-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libsqlite3-dev llvm make python3-openssl tk-dev wget xz-utils zlib1g-dev
curl https://pyenv.run | bash
cat <<EOF >> $HOME/.bashrc

# configure pyenv
export PATH="\$PATH:\$HOME/.pyenv/bin"
eval "\$(pyenv init --path)"
eval "\$(pyenv init -)"
eval "\$(pyenv virtualenv-init -)"
EOF
exec $SHELL

Use pyenv to set a Python version globally

pyenv install 3.10.1
pyenv global 3.10.1

User pyenv to set a Python version to the current directory

pyenv install 3.10.1
pyenv local 3.10.1

Check

python --version
# Python 3.10.1
pip --version
# pip 21.2.4 from /home/carlos/.pyenv/versions/3.10.1/lib/python3.10/site-packages/pip (python 3.10)

Why?

  1. focal/main/ $ARCH python3 still uses Python 3.8.
  2. ppa:deadsnakes/ppa has weird issues with pip and paths.
  3. Nobody got time for compiling Python from source.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment