Seahub 11 fails on Ubuntu 22.04 and 24.04 with python3.12 / works with python3.10 / works with virtualenv

I just updated from Seafile pro 11.0.12 to 11.0.14. I also updated my server yesterday from Ubuntu 22.04 to 24.04. On both 22.04 and 24.04, if I use the default system python3.12, the seahub service fails to start (seafile works fine). And it gives no useful information to troubleshoot why it fails to start. I installed python3.10 and used update-alternatives to switch my default python to 3.10, after which the seahub service starts and works fine.

The latest server guide recommends using a python3.12 virtual environment, but I didn’t see instructions for using the virtual environment with systemd service files. So this is the hacky solution I am currently using.

I edited the seafile.sh and seahub.sh to add this line to the scripts: source ā€œ/opt/seafile/python-venv/bin/activateā€. It’s not necessary to add it to the seafile.sh script in my case, but it might avoid future problems. Assuming your seafile is installed in /opt/seafile, here’s a one line command: sed -Ei ā€˜s/(END INIT INFO)/\1\nsource ā€œ/opt/seafile/python-venv/bin/activateā€/’ /opt/seafile/seafile-server-latest/seafile.sh /opt/seafile/seafile-server-latest/seahub.sh

The extra steps for making the python venv work with systemd is at the top of this page.
https://manual.seafile.com/deploy/start_seafile_at_system_bootup/#for-systems-running-systemd-and-python-virtual-environments

It is basically just a little script called from the systemd unit that will activate the venv, and then start the specific seafile component. Your solution is a little bit cleaner, but will be undone by future updates to seafile so you will have to make that edit again with each update.

1 Like

Für Debug: You need to edit gunicorn.conf.py and change daemon = True into = False.
When you then start seahub (./seahub.sh start) it gives you meaningful error message.

I’m running 3.12.3 without venv. You just need to install all the python dependencies. However pip3 does not work anymore with 24.04, so you have to use apt instead.

1 Like

Thank you for the tip on gunicorn. I was able to get detailed trace back logs. For some reason when I try to start seahub, python looks for old library files that haven’t been installed since Ubuntu 20.04. I got this error:
ImportError: libldap_r-2.4.so.2: cannot open shared object file: No such file or directory

I was able to resolve by creating symlinks:
cd /lib/x86_64-linux-gnu ; sudo ln -s libldap.so.2.0.200 libldap_r-2.4.so.2 ; sudo ln -s libldap.so libldap_r-2.4.so

Then I got this error:
ImportError: liblber-2.4.so.2: cannot open shared object file: No such file or directory

I tried creating symlinks again:
cd /lib/x86_64-linux-gnu ; sudo ln -s liblber.so.2.0.200 liblber-2.4.so.2 ; sudo ln -s liblber.so liblber-2.4.so

But now I’m getting this error:
ImportError: /lib/x86_64-linux-gnu/liblber-2.4.so.2: version `OPENLDAP_2.4_2’ not found (required by /usr/local/lib/python3.12/dist-packages/_ldap.cpython-312-x86_64-linux-gnu.so)

For some reason I don’t get any errors when using the virtual environment. I set up the run_with_venv.sh script and have it up and running. Thank you for your responses!