pythonlinuxarchlinuxpacman-package-manager

How to update python to the latest version on ArchLinux?


How to install the latest python version 3.11.0 on ArchLinux through pacman?

ArchLinux wiki says current version is 3.10, although python 3.11 has been officially released.

When running sudo pacman -Syyu p I'm welcomed with warning: python-3.10.8-3 is up to date.

Am I doing something wrong?


Solution

  • You can install multiple versions and implementations of Python independently of your distro's package manager using pyenv.

    1. Install pyenv with sudo pacman -S pyenv.
    2. Set up your shell for usage with pyenv https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv
    3. Install the Python version of your choice (please note that CPython will be built from source).
    pyenv install -l # This will list all available versions
    pyenv install 3.11.1 # This will install CPython 3.11.1
    
    1. Select the Python version as the default.
    pyenv shell 3.11.1 # Use this version only for this shell session
    pyenv local 3.11.1 # Use this version only when you are in this directory
    pyenv global 3.11.1 # Use this version as the default version
    

    Note that this will not replace Python installed by the package manager located at /usr/bin/python. Pyenv will only change the PATH to point python to its Python binary.