Skip to main content Link Search Menu Expand Document (external link)

Python 3.11 has been out for a couple of months now, and I’m keen to try it out. Not only is it reportedly faster, but it also includes Tomllib which is something I want to use for life-logging scripts I’m working on for my zettelkasten.

There’s no direct way to install this via apt in Bullseye, so I’ve two options: use a virtual environment, or install from source.

I could, of course, use Conda (and have done so on my laptop), but the machine I’m going to install onto has more limited resources. I’m using a server with a single core, and mighty gigabyte of memory, and 8 GB of diskspace, so running a full-blown Conda environment is likely to be problematic. Miniconda suggests it needs 400 meg to download and install alone. Once I start creating environments, I’m likely to outgrow my vps. So I’m going to install Python 3.11 from source.

Thankfully, the Python website has all the resources I need, so the installation is a fairly straightforward case of issuing a few commands.

First, I need to install the dependencies:

  • software-properties-common
  • wget
  • pkg-config
sudo apt install software-properties-common wget pkg-config

Then, for the download, unpacking and installation I’ll create a temporary directory

mkdir -p ~/scratch
cd ~/scratch

From there, it’s simply a case of downloading and unpacking:

## find latest version at
tar -xf Python-3.11.0.tar.xz
cd Python-3.11.0

and finally installing:

## configure and install
./configure --enable-optimizations
sudo make altinstall

You can check the installation by running python3.11 --version:

python3.11 --version

which should return Python 3.11.0

alternative install means that the new version is installed as python3.11 rather than python3, so you can run both the original version and the new one side-by-side. this should mean that the installation doesn’t break any existing scripts. As my machine doesn’t have any python2, I decided to use update-alternatives to make python point to the new python3.11:

sudo update-alternatives --install /usr/bin/python python3 /usr/local/bin/python3.11 1

That step’s optional, and certainly not for everyone, but it means that I can run python3.11 by simply typing python at the command line - perfect for my lazy fingers.