SeaHub fails to start (NameError: name '_mysql' is not defined)

Hello,

I am running Seafile on my Raspberry Pi 4B and ran into startup issues today.
Short summary on how I got here:

  • Seafile client no longer connected
  • nginx was giving a 502 bad gateway (I use a reverse proxy for https)
    • direct local connection also did not work
  • found out my mounted external HDD stopped working on which the seafile-data is located
    • some reboots and manual mounting later that was resolved
  • SeaHub no longer wanted to start (v7.1.5)
  • After failing to fix it, tried to upgrade to 8.0.3.
    • The upgrade script returned succesfully
  • SeaHub still fails to start, but due to a different issue

That is the point I am at now.

Error:

May 27 17:55:41 rpi-server systemd[1]: Starting Seafile...
May 27 17:55:41 rpi-server seahub.sh[27944]: Starting seahub (fastcgi) at 127.0.0.1:8000 ...
May 27 17:55:42 rpi-server seahub.sh[27944]: Traceback (most recent call last):
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/MySQLdb/__init__.py", line 18, in <module>
May 27 17:55:42 rpi-server seahub.sh[27944]:     from . import _mysql
May 27 17:55:42 rpi-server seahub.sh[27944]: ImportError: cannot import name '_mysql' from partially initialized module 'MySQLdb' (most likely due to a circular import) (/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/MySQLdb/
May 27 17:55:42 rpi-server seahub.sh[27944]: During handling of the above exception, another exception occurred:
May 27 17:55:42 rpi-server seahub.sh[27944]: Traceback (most recent call last):
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/manage.py", line 10, in <module>
May 27 17:55:42 rpi-server seahub.sh[27944]:     execute_from_command_line(sys.argv)
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/core/management/__init__.py", line 381, in execute_from_command_line
May 27 17:55:42 rpi-server seahub.sh[27944]:     utility.execute()
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/core/management/__init__.py", line 357, in execute
May 27 17:55:42 rpi-server seahub.sh[27944]:     django.setup()
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/__init__.py", line 24, in setup
May 27 17:55:42 rpi-server seahub.sh[27944]:     apps.populate(settings.INSTALLED_APPS)
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/apps/registry.py", line 114, in populate
May 27 17:55:42 rpi-server seahub.sh[27944]:     app_config.import_models()
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/apps/config.py", line 211, in import_models
May 27 17:55:42 rpi-server seahub.sh[27944]:     self.models_module = import_module(models_module_name)
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
May 27 17:55:42 rpi-server seahub.sh[27944]:     return _bootstrap._gcd_import(name[level:], package, level)
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "<frozen importlib._bootstrap_external>", line 855, in exec_module
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/contrib/sessions/models.py", line 1, in <module>
May 27 17:55:42 rpi-server seahub.sh[27944]:     from django.contrib.sessions.base_session import (
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/contrib/sessions/base_session.py", line 26, in <module>
May 27 17:55:42 rpi-server seahub.sh[27944]:     class AbstractBaseSession(models.Model):
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/db/models/base.py", line 117, in __new__
May 27 17:55:42 rpi-server seahub.sh[27944]:     new_class.add_to_class('_meta', Options(meta, app_label))
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/db/models/base.py", line 321, in add_to_class
May 27 17:55:42 rpi-server seahub.sh[27944]:     value.contribute_to_class(cls, name)
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/db/models/options.py", line 204, in contribute_to_class
May 27 17:55:42 rpi-server seahub.sh[27944]:     self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/db/__init__.py", line 28, in __getattr__
May 27 17:55:42 rpi-server seahub.sh[27944]:     return getattr(connections[DEFAULT_DB_ALIAS], item)
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/db/utils.py", line 201, in __getitem__
May 27 17:55:42 rpi-server seahub.sh[27944]:     backend = load_backend(db['ENGINE'])
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/db/utils.py", line 110, in load_backend
May 27 17:55:42 rpi-server seahub.sh[27944]:     return import_module('%s.base' % backend_name)
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
May 27 17:55:42 rpi-server seahub.sh[27944]:     return _bootstrap._gcd_import(name[level:], package, level)
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/django/db/backends/mysql/base.py", line 15, in <module>
May 27 17:55:42 rpi-server seahub.sh[27944]:     import MySQLdb as Database
May 27 17:55:42 rpi-server seahub.sh[27944]:   File "/opt/Seafile/seafile-server-8.0.3/seahub/thirdpart/MySQLdb/__init__.py", line 24, in <module>
May 27 17:55:42 rpi-server seahub.sh[27944]:     version_info, _mysql.version_info, _mysql.__file__
May 27 17:55:42 rpi-server seahub.sh[27944]: NameError: name '_mysql' is not defined
May 27 17:55:47 rpi-server seahub.sh[27944]: Error:Seahub failed to start.
May 27 17:55:47 rpi-server systemd[1]: seahub.service: Control process exited, code=exited, status=1/FAILURE
May 27 17:55:47 rpi-server systemd[1]: seahub.service: Failed with result 'exit-code'.
May 27 17:55:47 rpi-server systemd[1]: Failed to start Seafile.

In order to run some other services on my PI, I have a manually compiled python 3.9 version besides 3.7 and 2.7.

I checked and made sure that the users root, pi and seafile all have python3.7 when using the python3 command or pip3 command. I made sure that those also have all the required packages installed that are mentioned in the upgrade notes.

I also already installed

apt install libmariadbclient-dev

instead of the one mentioned in the notes since I am running debian 10.

Looking at the output above, seafile is still running somehow using python3.9. I have no clue if this even is an issue, I even made sure all the packages are installed in that python version as well.

I am completely at a loss. Hopefully someone can help.
Please let me know if I have to provide more information.

Thanks.