privacyIDEA stops working after upgrading Ubuntu 18.04 to 20.04

Apache’s error log says:

Python path configuration:
PYTHONHOME = ‘/opt/privacyidea’
PYTHONPATH = (not set)
program name = ‘python3’
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = ‘/usr/bin/python3’
sys.base_prefix = ‘/opt/privacyidea’
sys.base_exec_prefix = ‘/opt/privacyidea’
sys.executable = ‘/usr/bin/python3’
sys.prefix = ‘/opt/privacyidea’
sys.exec_prefix = ‘/opt/privacyidea’
sys.path = [
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named ‘encodings’

Well, after some sym-linking python3.6 > python3.8 Apache starts with no errors. But opening privacyIDEA causes a 500 Internal server error:

mod_wsgi (pid=13293): Exception occurred processing WSGI script ‘/etc/privacyidea/privacyideaapp.wsgi’.

ModuleNotFoundError: No module named ‘_cffi_backend’

Hi joerg.giencke,

replayed a do-release-upgrade from ubuntu 18.04 to ubuntu 20.04.
Ubuntu 20.04 comes with python 3.8 out of the box.
privacyidea use on my installation python 3.6.
In my case :

Remove old python links

cd /opt/privacyidea/bin/
rm python3.6 python3 python

Copy new python3.8 version to privacyidea directory

which python3
cp -a /usr/bin/python3 /opt/privacyidea/bin/python3

Link new python version

cd /opt/privacyidea/bin/
ln -s python3 python3.8
ln -s python3 python

Now we have to relink all broken links from /opt/privacyidea/lib/python3.6 to python3.8, so we make a copy of python3.6
Copy old python3.6 directory to python3.8

cp -a /opt/privacyidea/lib/python3.6 /opt/privacyidea/lib/python3.8

List all symbolic-links;

find /opt/privacyidea/lib/python3.8 -type l -exec ls {} ; | sort

relink: for this i used a little script:

cd /opt/privacyidea/lib/python3.8
for i in $(find /opt/privacyidea/lib/python3.8 -type l -exec ls {} ; | sort | sed ‘s|.*/||’); do
rm $i
ln -s /usr/lib/python3.8/$i $i
#last relink
rm config-3.6m-x86_64-linux-gnu
ln -s /usr/lib/python3.8/config-3.8-x86_64-linux-gnu/ config-3.8m-x86_64-linux-gnu

after that, we repaired all broken links
If we restart apache2, we get the last error which joerg.giencke has written:

Upgrade all python modules
The requirements of privacyidea are found here:


pip3 install -r /opt/privacyidea/lib/privacyidea/requirements.txt -t /opt/privacyidea/lib/python3.8/site-packages -U

restart apache