[RESOLVED] Python Compatibility Issues

If you have a specific technical inquiry, construct your post with the following:

Summary

When installing Kolibri to a fresh Raspberry Pi OS, on a Raspberry Pi 5, from the repositories, the service won’t start with some Python errors. (I don’t have the errors atm, will try to add them later)

Technical details

  • Operating System: Debian GNU/Linux 12 (bookworm)
  • Kernel: Linux 6.6.20+rpt-rpi-2712
  • Architecture: arm64

Cause

Raspberry Pi OS comes with Python3.11, which is throwing the errors.

Workaround

Install Python3.8

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
wget https://www.python.org/ftp/python/3.8.19/Python-3.8.19.tgz
tar xf Python-3.8.19.tgz
cd Python-3.8.19
./configure --enable-optimizations
make -j 2
sudo make altinstall

You now have Python3.8, but the python command is still linked to python3.11, so we can remove the existing link and link it to 3.8:

PYTHON_PATH=$(which python)
sudo rm $PYTHON_PATH
sudo ln -s $(which python3.8) $PYTHON_PATH

After that, install Kolibri:

sudo apt-get install dirmngr
sudo su -c 'echo "deb http://ppa.launchpad.net/learningequality/kolibri/ubuntu bionic main" > /etc/apt/sources.list.d/learningequality-ubuntu-kolibri.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys DC5BAA93F9E4AE4F0411F97C74F88ADB3194DD81
sudo apt-get update
sudo apt-get install kolibri

Hi @rbgtk,

Thanks for this - we have definitely seen issues previously with Python 3.11 on Debian based OSes, due to different Python 3 packages being installed via apt. This github issue describes some of the issues we have seen previously: 0.16.0 RC1 fails if Samba/Ansible/etc are installed (e.g. with python3-markdown) on the same OS · Issue #11895 · learningequality/kolibri · GitHub

We had resolved all of the issues described above in the 0.16.0 release, so it seems possibly you’ve uncovered another? If you can retrieve the errors that you saw when attempting to use Python 3.11, that would be very helpful.

Kind Regards,
Richard

Hi @richard,

Welp, I’m unable to reproduce it, I tried twice on two completely fresh installs last week. Running the same commands now doesn’t produce the errors anymore.

Going through my search history then, the error messages I was looking at were

ImportError: cannot import name 'Iterable' form 'collections'

as well as

SyntaxWarning: "is" with a literal. Did you mean "=="?

I’m sorry for raising false concerns, I don’t know why it wasn’t working then vs why it’s working now. I flashed another sd card just to get these error messages :sweat_smile:

Best regards,
rbgtk

This error:

ImportError: cannot import name ‘Iterable’ form ‘collections’

Is definitely something you would see from running a version of Kolibri that did not explicitly support Python 3.11, so that’s the only thing I can think of off the top of my head. That support was added during one of the 0.15 patches.

The SyntaxWarning is, unfortunately, coming from an external library, so the best we could do is suppress the warning for the future.

Glad that it appears to be working now, at least!

Kind Regards,
Richard