5

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?

Ruan Molinari
  • 99
  • 3
  • 10
  • 5
    Someone has to actually do the work to package Python 3.11 for Arch, and then all the other packages in Arch need to be tested to work with it. All these things take time. – Charles Duffy Nov 11 '22 at 16:49
  • 2
    If you want a distro and package manager that can control for interdependencies and let you install newer tools (or older ones, or patched ones, etc etc) while still keeping other versions in place for the things that need them, might I interest you in [NixOS](https://nixos.org/)? Mind, you can also install Nix (the package manager itself) on top of Arch if you choose. – Charles Duffy Nov 11 '22 at 16:50
  • 2
    (...and insofar as everything discussed is true for _all_ packages on Arch, vs being specific to Python or programming tools, I'd suggest that this question would be more topical on [unix.se] rather than here) – Charles Duffy Nov 11 '22 at 16:51
  • Thank you @CharlesDuffy, I will take a look at NixOS. Also, thanks for pointing me out to Unix StackExchange. Will post there next time. – Ruan Molinari Nov 11 '22 at 17:14
  • 2
    I recommend to use [pyenv](https://github.com/pyenv/pyenv) to install the latest version. For development, it's the best. – jik777 Nov 11 '22 at 19:18
  • The issue was addressed on the [arch-dev-public](https://lists.archlinux.org/archives/list/arch-dev-public@lists.archlinux.org/thread/ZK57U5LPIDDJWPXWU5DSIYSI3EWUBGPP/) mailing list. – Steve Ward Nov 21 '22 at 01:01

3 Answers3

9

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.

user18686221
  • 91
  • 1
  • 4
2

Use AUR like "yay" to get the new python3.11.

If you haven't installed yay on your system, setup yay by following these instructions

Run this command after setting up yay in your system:

yay -S python311
  • Thank you, python311 is installed now. But how do I run it? `python311` returns `command not found`, and `python -V` returns `Python 3.10.8` – Ruan Molinari Nov 11 '22 at 17:18
  • 1
    @RuanMolinari you need to add newly installed python to path. You can do that by adding `export PATH=”$PATH:/usr/local/bin/python311”` to your .bashrc file – Imagine Eyes Nov 12 '22 at 14:48
-4

You can update python to the latest version on ArchLinux using the following command:

pacman -Syu python

  • 2
    This won't install 3.11. The latest version in the core repos is 3.10. – Holloway Nov 14 '22 at 17:29
  • To clarify, this installs the "latest version **available in AUR at the time of the command**". Never latest release since Python devs don't seem to publish to AUR on their own. – OneCricketeer Jan 10 '23 at 00:51